- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I match a comma separated list against a value in MySQL?
Let us first create a table −
mysql> create table DemoTable ( `Values` varchar(50) ); Query OK, 0 rows affected (1.15 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('23,45,78,56'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('384,476,7456'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('68,8,88,89'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('78,80,84'); Query OK, 1 row affected (0.19 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+--------------+ | Values | +--------------+ | 23,45,78,56 | | 384,476,7456 | | 68,8,88,89 | | 78,80,84 | +--------------+ 4 rows in set (0.00 sec)
Following is the query to match a comma-separated list against a value −
mysql> select *from DemoTable where find_in_set('8',`Values`)!=0;
This will produce the following output −
+------------+ | Values | +------------+ | 68,8,88,89 | +------------+ 1 row in set (0.00 sec)
- Related Articles
- Check if value exists in a comma separated list in MySQL?
- How can I search within a table of comma-separated values in MySQL?
- How to set a comma separated list as a table in MySQL?
- Display MySQL Results as comma separated list?
- Can I search for particular numbers in a MySQL column with comma separated records using a MySQL query?
- Display duplicate record as a distinct value with corresponding values as distinct comma separated list in MySQL?
- Searching from a comma separated MySQL column?
- Regex to find string and next character in a comma separated list - MySQL?
- How would you make a comma-separated string from a list in Python?
- MySQL query to retrieve records from the part of a comma-separated list?
- MySQL query to get a single value from position of comma-separated string?
- How to use a comma-separated string in an `IN ()` in MySQL?
- How to create a comma separated string from a list of string in C#?
- How to sum a comma separated string (string with numbers) in MySQL?
- Convert a List of String to a comma separated String in Java

Advertisements