Why can’t I access prostatus in WHERE clause, whilst I can access it ORDER BY clause.
Eg:
SELECT …,IF((p2.pr_status = 0 OR psd2.link_status = 0),0,1) AS prostatus
FROM …
WHERE
prostatus = 1 AND p2.pr_type_id = 1 …
<- Doesn’t work (Unknown column ‘prostatus’ in ‘where clause’). Yet, the following DOES work:
SELECT …,IF((p2.pr_status = 0 OR psd2.link_status = 0),0,1) AS prostatus
FROM …
WHERE
p2.pr_type_id = 1 …
ORDER BY prostatus DESC
Assuming everything else is the same in the query.
Thanks