How to use CASE appropriately for executing SELECT query based on user input ?
On executing following query :
SELECT
CASE WHEN user_input_variable = 'y' THEN
(SELECT * FROM table_foo WHERE bar = '6f322766-0ec0-4d24-840f-c857a82a6efe')
ELSE
(SELECT 0)
END
If the user has selected 'y' then it should return records from the table, else it should return an empty result set.
I am getting error:
Operand should contain 1 column(s)
SELECT * FROM table_foo.SELECT 0returns a different number of columns than the fist one.