I have a table with a varchar
column categoryIds
. It contains some IDs separated by commas, for example:
id categoryIds
--------------------
1 3,7,12,33,43
I want to do a select statement and check if an int exists in that column. Something like this:
select *
from myTable
where 3 in (categoryIds)
I know this is possible in MySQL by doing this, but can it be done in SQL Server as well?
I have tried casting the int to a char, which runs the following statement:
select *
from myTable
where '3' in (categoryIds)
But it doesn't look like there's any "out of the box" support for comma separated lists as it returns nothing.