I am getting an input in one of my variables and basically I want to do something like
SELECT * FROM PEOPLE
WHERE
IF @INPUT = 1
ITEMID = 16 OR ITEMID = 13
ELSE IF @INPUT = 2
ITEMID = 11 OR ITEMID = 14
ELSE
ITEMID = 0
Is there a way to do this, please forgive if this is wrong but I wanted to portray my issue as easily understandable as possible.
I tried with CASE before this like
WHERE
CASE @INPUT
WHEN 1 THEN ITEMID = 16 OR ITEMID = 13
WHEN 2 THEN ITEMID = 11 OR ITEMID = 14
ELSE ITEMID = 0
END
But all of these approaches throw errors, I would appreciate a good advise, more efficient way to do this if possible.
Thank you for the help.
1 Answer