

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 to find a particular varchar id in MySQL from a list of values?
To get a particular varchar ID from a list, you can use FIND_IN_SET(). Let us first create a table −
mysql> create table DemoTable ( Id varchar(255) ); Query OK, 0 rows affected (0.51 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('10,100,1000'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('101,120,2'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('3,4,5'); Query OK, 1 row affected (0.11 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-------------+ | Id | +-------------+ | 10,100,1000 | | 101,120,2 | | 3,4,5 | +-------------+ 3 rows in set (0.00 sec)
Following is the query to find the id in MySQL −
mysql> select *from DemoTable where find_in_set('2',Id);
This will produce the following output −
+-----------+ | Id | +-----------+ | 101,120,2 | +-----------+ 1 row in set (0.03 sec)
- Related Questions & Answers
- Find date record after a particular date from a column with VARCHAR type in MySQL
- How to find string count of a particular id in a column using a MySQL query?
- How to get a value more than a particular value from varchar column in MySQL?
- MySQL query to get max id from varchar type and the values in numeric?
- MySQL query to sum the values of similar columns from two different tables for a particular ID
- Get maximum date from a list of varchar dates in MySQL
- Updating last entry of a particular ID in MySQL
- How to find a specific record from a list of values with semicolon in MySQL?
- Find maximum value from a VARCHAR column in MySQL
- How to alter a MySQL Column from varchar(30) to varchar(100)?
- In MySQL how to replace all NULL values in a particular field of a particular table?
- How to select particular range of values in a MySQL table?
- In MySQL, which function we can use to find the index position of a particular string from a list of strings?
- How to select only non - numeric values from varchar column in MySQL?
- MySQL Query a List of Values?
Advertisements