> Is this a bug?  I can't find an answer to this question in FAQs 
> or archives.
> 
> CREATE TABLE aa ( a int);
> INSERT INTO aa VALUES (1),(2),(3),(2),(4),(5),(1),(6),(3);
> 
> the following :
> mysql> select a,count(*) as z from aa where z>1 group by a;
> 
> displays this error:
> ERROR 1054: Unknown column 'z' in 'where clause'
> 
> Why isn't z recognized as a column identifier?

Because you should be using HAVING rather than WHERE:

        select a,count(*) as z from aa group by a having z>1;

/ Carsten
--
Carsten H. Pedersen
keeper and maintainer of the bitbybit.dk MySQL FAQ
http://www.bitbybit.dk/mysqlfaq



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to