I've started learning SQL and I'm trying to reduce my repetition. Can someone help with this?
SELECT email
FROM users
WHERE campaign LIKE 'BBB-2'
AND test ='lions'
OR test = 'tigers'
OR test = 'bears';
I've started learning SQL and I'm trying to reduce my repetition. Can someone help with this?
SELECT email
FROM users
WHERE campaign LIKE 'BBB-2'
AND test ='lions'
OR test = 'tigers'
OR test = 'bears';
Use
in
:Notes:
this solves a logical prescendence issue in your original query: the
OR
ed condition needed to be surrounded by parenthesesI replaced the
LIKE
condition with an equality check; there is no point usingLIKE
when the right operand contains no wildcard