mangesh santharam

mangesh santharam

  • NA
  • 230
  • 6.7k

MySQL query finding values in a comma separated string

Sep 1 2018 10:14 AM
I have a field coursecode (varchar(50)) in a my table pcp that contains a comma delimited string such as .1,2,5,12, 15 Each number representing the available courses. When running the query select * from pcp where coursecode like '%1%' to get all the coursecode (coursecode=1), I also get the course who's code is xyz (=12) and abc(=15). How should I rewrite the query so that is selects ONLY the coursecode 1 and not all coursecode containing the number 1?

Answers (1)