Is something wrong with this query

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
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Is something wrong with this query

Post by GeXus »

Could anyone tell me what is wrong with this query? Is the Syntax wrong?

Code: Select all

mysql_query("SELECT count(*) as Impressions, count(distinct IP) as Unique, Keyword as Keyword FROM `AdTracking` WHERE `PublisherID` = $PublisherID and DT >= $DateStart")or die(mysql_error());

Thanks!
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

what is the error you get?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

'unique' is a reserved word in MySQL. change your alias to something else.....
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

Burrito wrote:'unique' is a reserved word in MySQL. change your alias to something else.....
I did not look at so keenly as burrito did, do not change alias but put backticks around it
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

Excellent, thank you!
Post Reply