I'm trying to write a query to look-up rows which contain one or more of comma-separated values. Please see scenario below:
Table: Events, target row to lookup is called "courses" The data in the courses column is a comma separated string of course codes.
- ABC123,XYZ345,ABC987
- ABC123
- ABC123,ABC987
- XYZ345,ABC123
Now what I want to do is to do a Select * from events where courses in ("ABC123","XYZ345"); However this returns no results.
What I want is that the where lookup to get me all rows that CONTAINS ABC123 OR XYZ345.
Could someone please help me do this?
CodePudding user response:
You could use like
, the %
are wildcards.
select *
from events
where courses like "