Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I have some comma separated values in database column and I have a value to check if that value exists in those comma separated value in database

colleges table bellow

ID Name Courses
1 ABC 1,2,3,4,5

CourseID = 1;

q = "SELECT * FROM colleges WHERE Courses = CourseID";

that ID is an (int) value but I have some comma-separated values in the Courses column.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

is there any way in SQL to solve this problem

>Solution :

You should fix your table design and never store data as comma separated.

You could use FIND_IN_SET

SELECT * FROM colleges where FIND_IN_SET(1, Courses);

Demo

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading