my target where qq blank AND match ab with OR condition.
SELECT
xyz
FROM
admin
WHERE
qq = ''
AND ab LIKE 'some1'
OR ab LIKE 'some2'
OR ab LIKE 'some3'
my target where qq blank AND match ab with OR condition.
SELECT
xyz
FROM
admin
WHERE
qq = ''
AND ab LIKE 'some1'
OR ab LIKE 'some2'
OR ab LIKE 'some3'
Depending on your collation, this particular query can be written like this:
SELECT xyz
FROM col_admin
WHERE qq = ''
AND ab IN('some1','some2','some3')
More generally, the astute use of parentheses will suffice...
SELECT xyz
FROM col_admin
WHERE qq = ''
AND ( ab LIKE 'some1'
OR ab LIKE 'some2'
OR ab LIKE 'some3'
)
The script syntax will be as follow. This will ensure the QQ Is blank and ab match any of the text.
SELECT xyz
FROM col_admin
WHERE qq = ''
AND (ab LIKE '%some1%' OR ab LIKE '%some2%' OR ab LIKE '%some3%')
Use in:
WHERE qq = '' AND ab IN ('some1', 'some2', 'some3')
You are not using wildcards, so there is no need to use LIKE.
You don't seem to understand how AND and OR work together. Because you don't understand precedence (yet), use parentheses whenever your conditions have both AND and OR.
You can accomplish this by putting braces in the condition
SELECT
xyz
FROM
col_admin
WHERE
qq = ''
AND (ab LIKE 'some1'
OR ab LIKE 'some2'
OR ab LIKE 'some3')