At 15:30 -0600 1/18/02, Rick Emery wrote:
>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?
As others have pointed out, your query requires a HAVING rather than a
WHERE. What hasn't been pointed out, which is worth knowing, is that
column aliases cannot be used in *any* WHERE clause.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.