.oO(Michael White)
>VernMan wrote:
>> I using the AS clause to define 'myZip' as seen
below, but am unable to use the
>> WHERE clause using the defined column. This is a
scaled down version of what I
>> am trying to do but will sufice as an example:
>>
>> SELECT npp_users.ZIP as myZip
>> FROM users
>> WHERE myZip = `00010`
>>
>> Anyone have any clues?
>>
>
>WHERE myZip = "00010"
Nope. The correct delimiter for strings in SQL is the single
quote
(assuming that the ZIP code is stored as a string - as a
numeric even
the single quotes would be wrong).
The problem here is that you can't use alias names in a WHERE
clause.
You either have to use the same expression as in the SELECT
part (here:
npp_users.ZIP) or a HAVING clause.
B.1.5.4. Problems with Column Aliases
http://dev.mysql.com/doc/refman/5.0/en/problems-with-alias.html
Micha