First query
This query works fine and the engine does not complain about it
SELECT id
FROM agencies
WHERE id IN ((SELECT id FROM agencies))
ORDER BY id;
Second query
This one does not work, the engine is complaining about Subquery returns more than 1 row, when -according to me- I am doing the exact same thing when @param_1 IS NULL
SELECT
@param_1 := NULL,
SELECT id
FROM agencies
WHERE id IN (CASE WHEN @param_1 IS NULL THEN (SELECT id FROM agencies) ELSE 1 END )
ORDER BY id;
Does anybody see why the engine is complaining about the second query when it isnt for the first query ?
Thanks in advance,
CASE expects a scalar, single value. Not a record set.
OR
Another choice is to use IF