group by problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

group by problem

Post 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]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.
Post Reply