tags:

views:

50

answers:

3

Query issues, for the life of me i cant figure out what is wrong with this query

HAVING distance  ='10'
GROUP BY c.ancient,
   c.ant_name,
   p.upper,
   p.name,

ERROR 1064 (42000): 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 c.city_id, c.city_name, p.prop_ynow_id, p.Name, pr.PRE_Ident SELECT dis' at line 1

+5  A: 

HAVING goes after GROUP BY. MySQL is picky this way.

Ignacio Vazquez-Abrams
A: 

I don't do MySQL, but in the SQL I'm used to, the HAVING clause needs to go after the GROUP BY clause.

SeaDrive
+1  A: 

A little late to the party but Queries in any standard SQL from my experience generally have to go:

INSERT, DELETE, SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY

Order.

Cericme