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
ORed condition needed to be surrounded by parenthesesI replaced the
LIKEcondition with an equality check; there is no point usingLIKEwhen the right operand contains no wildcard