Why doesn’t the following query work? Mysql complains about z – can’t I use an alias in the WHERE clause?
SELECT x + y AS z, t.* FROM t
WHERE
x = 1 and
z = 2
The error that I get is:
Error Code : 1054
Unknown column 'z' in 'where clause'
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
http://dev.mysql.com/doc/refman/5.0/en/problems-with-alias.html
Try this, instead: