Alias in WHERE Clause
Posted on Thursday, March 18, 2010 in MySQL
Aliases are not used in WHERE clause, instead they should be used in HAVING clause, like this:
SELECT customer_email, COUNT(customer_email) AS 'duplicate_customer_email'
FROM customers
WHERE customer_email != ''
GROUP BY customer_email
HAVING duplicate_customer_email > 1
ORDER BY duplicate_customer_email DESC
