I have a VARCHAR which value aaa or bbb let say
depend on this I have to make
SELECT x FROM y WHERE y AND som = 1
or
SELECT x FROM y WHERE y AND som = 2
I there any way to make this like
SELECT i AS j,
case xxx
when z then som1
else som2
end as ABC
FROM ...
//EDIT
I want make something like this (lets say its pseudocode 😉 )
variable VARCHAR;
SELECT id FROM table WHERE age =
CASE variable
WHEN 'aaa' THEN 21
ELSE 'bbb' THEN 99
END
You could use a
CASEstatementHowever, it may be more efficient and easier to read to just do an
OR