Page 1 of 1

CONTACT() AS something - something in WHERE clause

Posted: Fri Jan 06, 2006 11:34 am
by anjanesh
Any way to get this work in MySQL 4.0.x?

Code: Select all

SELECT *,
CONCAT(contact.FirstName,contact.LastName,contact.Phone) AS Uniq
FROM `contacts` contact
WHERE Uniq = 'MyFirstnameMyLastname101-10101-101'
Thanks

Posted: Fri Jan 06, 2006 11:38 am
by timvw
You should repeat the complete statement...

Code: Select all

SELECT *, CONCAT(contact.FirstName,contact.LastName,contact.Phone) AS Uniq
FROM `contacts` contact
WHERE CONCAT(contact.FirstName,contact.LastName,contact.Phone) = 'MyFirstnameMyLastname101-10101-101'

SQL queries are processed as following:
1 - from
2 - where
3 - group by
4 - having
5 - select
6 - order by

By the time the where clause is processed, it doesn't know about aliases defined in the where clause...

Posted: Fri Jan 06, 2006 12:14 pm
by anjanesh
Ah...Thanks