Select in SQL

Hi expert,

How can I select data if the column of my table contains "62,96,103,104,216,222,314,329,385,405,417,459,468,538,560,572,600,602".

I try:  select * from mytable where idlist like '%,417,%'
But it will fail if the id number 417 is at the first position.

Please help.
Who is Participating?
Aneesh RetnakaranConnect With a Mentor Database AdministratorCommented:
select * from myTable where idlist like '%,417,%' or idlist like '417,%' or idlist like '%,417' or idlist ='417'
alexcryoutAuthor Commented:
Thanks. It works.
Another way to do this is to add comma at start and end of the list
select * from mytable where ',' + idlist + ',' like '%,417,%'

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.