How to refer ‘decider’ in the where clause from the following mysql query?
SELECT *,
CASE
WHEN (cond1) THEN 1
WHEN (cond2) THEN 2
END as decider
FROM t1,
t2
WHERE cond12
AND decider <> NULL
I tried it, and I got a 1054: Unknown column in where clause error.
Use:
GROUP BYclauseIS NULLorIS NOT NULL(where appropriate) becauseNULLis not a value — it’s a placeholder for the lack of any value, which requires special handling in SQL