Skip to main content
Known Participant
November 3, 2009
Question

Sql error 1064

  • November 3, 2009
  • 1 reply
  • 725 views

I'm using the following SQL code, to show the total sum of 2 columns from 4 tables:

SELECT (SELECT SUM(`STARTING` +`SUBS USED`)

FROM `player stats 0910`

WHERE `PLAYER ID` = '118') + (SELECT SUM(`App` + `Sub`) FROM `player stats 0809` WHERE `Player` = 'Joe Bloggs')  + (SELECT SUM(`App` + `Sub`) FROM `player stats 0708` WHERE `Player` = 'Joe Bloggs')  + (SELECT SUM(`App` + `Sub`) FROM `player stats 0607` WHERE `Player` = 'Joe Bloggs')  AS 'Total Appearances'

When I test the SQL in a recordset in Dreamweaver (CS4), it works fine and gives me the correct total, but when I try to upload/add it to the page, I get a MM_Error #1064.

Has anyone come across this before, or know why this is happening?

Many Thanks

Andy

This topic has been closed for replies.

1 reply

Participating Frequently
November 3, 2009

SQL error 1064 or MM_Error #1064?? What is the complete error?

The sql syntax does not look like valid sql, although MySQL might possibly allow it.

Before going any further, can you please explain why you have more than one player stats table? What do the numbers after the table name signify?

info261Author
Known Participant
November 3, 2009

The error is MM_Error 1064. It works fine in Dreamweaver when I test it, and also on the MySQL side, through PHPadmin.

The numbers after the table are just for each season/year that the players have played. The stats for the previous years, 06/07, 07/08 etc were obviously already completed when I started doing the site. Would you try and put all these into one table?

Cheers

Andy

Participating Frequently
November 3, 2009

>Would you try and put all these into one table?

Absolutely. Having multiple tables storing the same type of data was a huge design mistake. Having all of that data in single table would make the problem with your current query disappear - as well as many more problems you will encounter down the road.

If there is a legitamate reason for splitting the data into individual tables, then I would suggest creating a view which would contain a union of all tables that can be used when you are working on problems like this that span multiple years.