How to skip an empty LIKE operator in a multiple LIKE query?
- by alex
I notice my query doesn't behave correctly if one of the like variables is empty:
SELECT name
FROM employee
WHERE name LIKE '%a%'
AND color LIKE '%A%'
AND city LIKE '%b%'
AND country LIKE '%B%'
AND sport LIKE '%c%'
AND hobby LIKE '%C%'
Now when a and A are not empty it works but when a, A and c are not empty the c part is not excuted so it seems?
How can I fix this?