Using a derived value in a MySQL WHERE clause doesn’t work. Is there a way to simulate this behavior? Below is an example query that fails because of the WHERE count > 5 line:
SELECT
title,
company_id,
count( id ) as count
FROM
table
WHERE
count > 5
GROUP BY
title,
company_id
Aggregates cannot be used in
WHERE, but rather inHAVING. And you will need to add aGROUP BYclause.