How can I use LIKE operator with the OR operator in SQL Server 2005? For example:
SELECT *
FROM table
WHERE column_name LIKE '%boo%' OR '%bar%'
This does not seems to work !
EDIT 1 : RESPONSE TO FIRST ANSWER POSTED:
Cool, that works ! but I just found for the first time that your order conditions do not work with like … I want to ask is this normal or am I making a mistake? please see below to see what I mean
select *
from <table>
where col_name = 'VAL-QWE'
AND scenario like '%xxx%'
OR scenario like '%yyy%'
if you execute this query, sql server does not cares for col_name = 'VAL-QWE' condition at all, it just looks at the like condition ?
You need to repeat what the condition is being tested on. In this case, you need to repeat
column_namein your second conditionallikeclause.The
likeor any conditional test does not persist from the previous statement/test.