* David Katz
> I am trying to do a select statement where I am using one of the
> aliases in the where clause.  I keep getting an error that the field
> does not exist.

>From the manual: "Note that standard SQL doesn't allow you to refer to an
alias in a WHERE clause. This is because when the WHERE code is executed the
column value may not yet be determined."

<URL: http://www.mysql.com/doc/en/Problems_with_alias.html >

> example:
>
> Select invno, invdate, invamt, left(invdate,2) as month from
> salesfile where
> month = '01'
>
> MySql keeps telling me that month is not a field.  Is there a way to do
> this?

Yes, simply repeat the expression:

Select invno, invdate, invamt, left(invdate,2) as month
  from salesfile
  where left(invdate,2) = '01'

--
Roger


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to