
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Comma separated argument applicable for IN operator in MySQL?
Use FIND_IN_SET() for command separated argument. Let us first create a table −
mysql> create table DemoTable604 (Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,Title varchar(100)); Query OK, 0 rows affected (0.51 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable604(Title) values('MySQL'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable604(Title) values('C++'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable604(Title) values('MongoDB'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable604(Title) values('Java'); Query OK, 1 row affected (0.14 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable604;
This will produce the following output −
+----+---------+ | Id | Title | +----+---------+ | 1 | MySQL | | 2 | C++ | | 3 | MongoDB | | 4 | Java | +----+---------+ 4 rows in set (0.00 sec)
Here is the query for comma separated argument −
mysql> select *from DemoTable604 where find_in_set(Title,'C++,MongoDB');
This will produce the following output −
+----+---------+ | Id | Title | +----+---------+ | 2 | C++ | | 3 | MongoDB | +----+---------+ 2 rows in set (0.00 sec)
- Related Articles
- Count values from comma-separated field in MySQL?
- How to search for particular strings between comma separated values in MySQL?
- Fetch records from comma separated values using MySQL IN()?
- Display MySQL Results as comma separated list?
- Searching from a comma separated MySQL column?
- Remove specific word in a comma separated string with MySQL
- Find integer in text data (comma separated values) with MySQL?
- How to include quotes in comma separated column with MySQL?
- Check if value exists in a comma separated list in MySQL?
- How to use a comma-separated string in an `IN ()` in MySQL?
- How to fetch random rows in MySQL with comma separated values?
- Can I search for particular numbers in a MySQL column with comma separated records using a MySQL query?
- How to set a comma separated list as a table in MySQL?
- Find specific records from a column with comma separated values in MySQL
- How to sum a comma separated string (string with numbers) in MySQL?

Advertisements