8 messages in com.mysql.lists.mysqlRe: Column Alias Bug??
FromSent OnAttachments
Rick Emery18 Jan 2002 13:29 
Fournier Jocelyn [Presence-PC]18 Jan 2002 13:36 
Rick Emery18 Jan 2002 13:47 
Carsten H. Pedersen18 Jan 2002 14:21 
Paul DuBois18 Jan 2002 14:53 
Steve Rapaport19 Jan 2002 13:18 
DL Neil19 Jan 2002 13:45 
DL Neil20 Jan 2002 05:38 
Subject:Re: Column Alias Bug??
From:Paul DuBois (pa@snake.net)
Date:01/18/2002 02:53:29 PM
List:com.mysql.lists.mysql

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.