Page 1 of 1

group by problem

Posted: Thu Feb 08, 2007 5:03 am
by itsmani1
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


group by error, any help
[syntax="sql"]SELECT AllProductions.EventID, AllProductions.OpponentEventID, date_format( AllProductions.EventDate, '%c' ) AS mydate
FROM AllProductions
WHERE AllProductions.`EventID` = 161 
OR AllProductions.`OpponentEventID` =161 
ORDER BY AllProductions.EventDate
GROUP BY mydate
LIMIT 0 , 30 
has following error:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP BY mydate
LIMIT 0, 30' at line 1



feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Feb 08, 2007 6:07 am
by volka
Take a look at http://dev.mysql.com/doc/refman/5.0/en/select.html and check the mandatory order of ORDER BY, GROUP BY, LIMIT in a select statement.