Reputation: 771
I am using sql server. I have a table
Company
ABC
XYZ
ABC,XYZ
When I run a like query where company like '%ABC%'
I get the record containing only ABC
and not ABC,XYZ
How to get both the records?
Upvotes: 0
Views: 934
Reputation: 6043
select company from tablename where company like '%ABC%'
it would work irrespective of presence of comma or any other character
Upvotes: 1
Reputation: 247610
First, you should not contain comma separated list in one column. Doing so, you will run into issues trying to query the data.
Second, your code should work:
select *
from t
where company like '%ABC%'
See a SQL Fiddle with a Demo
Upvotes: 7