
- 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
How select specific rows in MySQL?
To select specific rows, use FIND_IN_SET() function in MySQL. Let us first create a table −
mysql> create table DemoTable ( ListOfValues varchar(200) ); Query OK, 0 rows affected (0.31 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('112,114,567,Java,345'); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable values('222,214,256'); Query OK, 1 row affected (0.06 sec) mysql> insert into DemoTable values('2,567,98,C'); Query OK, 1 row affected (0.06 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+----------------------+ | ListOfValues | +----------------------+ | 112,114,567,Java,345 | | 222,214,256 | | 2,567,98,C | +----------------------+ 3 rows in set (0.00 sec)
Following is the query to select specific rows in MySQL −
mysql> select *from DemoTable where find_in_set('2',ListOfValues) >0;
This will produce the following output −
+--------------+ | ListOfValues | +--------------+ | 2,567,98,C | +--------------+ 1 row in set (0.03 sec)
- Related Articles
- Select specific rows in a range with MySQL?
- How can I select rows which fall on a specific day of week in MySQL?
- How to select last two rows in MySQL?
- Select rows containing a string in a specific column with MATCH and AGAINST in MySQL
- Select rows that contain specific text using Pandas
- How to select last 10 rows from MySQL?
- What is the most efficient way to select a specific number of random rows in MySQL?
- How to select rows with condition via concatenate in MySQL?
- How to select MySQL rows in the order of IN clause?
- Select two random rows in a MySQL database?
- Randomly SELECT distinct rows in a MySQL table?
- Select all rows except from today in MySQL?
- How do I select 5 random rows from the 20 most recent rows in MySQL?
- MySQL query to select too many rows?
- MySQL query to select multiple rows effectively?

Advertisements