How can I pass a "solver" to a where clause from the following mysql query?
1 answer
Using:
SELECT *,
CASE
WHEN (cond1) THEN 1
WHEN (cond2) THEN 2
ELSE NULL
END as decider
FROM t1,
t2
WHERE cond12
HAVING decider IS NOT NULL
- The earliest MySQL allows column aliases - this is a suggestion
GROUP BY
- You need to use
IS NULL
orIS NOT NULL
(optionally) because it isNULL
not a value - it is a placeholder for missing any value that requires special handling in SQL
+1
source to share