List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:January 18 2002 10:53pm
Subject:Re: Column Alias Bug??
View as plain text  
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.
Column Alias Bug??Rick Emery18 Jan
  • Re: Column Alias Bug??Fournier Jocelyn [Presence-PC]18 Jan
  • RE: Column Alias Bug??Carsten H. Pedersen18 Jan
  • Re: Column Alias Bug??DL Neil19 Jan
  • Re: Column Alias Bug??Steve Rapaport19 Jan
  • Re: Column Alias Bug??DL Neil19 Jan
RE: Column Alias Bug??Rick Emery18 Jan
Re: Column Alias Bug??Paul DuBois18 Jan