Unknown Column

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
mrlayance
Forum Commoner
Posts: 31
Joined: Mon Dec 07, 2009 11:53 am

Unknown Column

Post by mrlayance »

Code: Select all

SELECT `prov`, `log` , `name` , count(*) as `count` FROM syslog WHERE `time` LIKE "Dec 20 %" AND `prov` = 'NB' AND `count` >= 20 GROUP By `prov`, `log`,`name` ORDER BY `count` DESC
I get an error says column `count` does not exist when I add the `count` >= 20?

I might be doing this wrong, but it has worked before?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Unknown Column

Post by AbraCadaver »

You can't use a column alias in a where clause and this query really isn't making any sense to me.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
User avatar
DigitalMind
Forum Contributor
Posts: 152
Joined: Mon Sep 27, 2010 2:27 am
Location: Ukraine, Kharkov

Re: Unknown Column

Post by DigitalMind »

Code: Select all

HAVING count(*) >= 20
Post Reply