We can get records as a result set by providing specific string and column names as parameters to the FIND_IN_SET() function. We also need to use the WHERE clause with the FIND_IN_SET() function. To understand it, we use the data from table "student_info" as shown below:
mysql> Select * from student_info; +------+---------+----------+------------+ | id | Name | Address | Subject | +------+---------+----------+------------+ | 101 | YashPal | Amritsar | History | | 105 | Gaurav | Jaipur | Literature | | 125 | Raman | Shimla | Computers | +------+---------+----------+------------+ 3 rows in set (0.00 sec)
Now, the following query will get specific records as result set using FIND_IN_SET() function where student name is "Raman":
mysql> Select Id, Name, Subject from Student_info Where FIND_IN_SET('Raman',Name); +------+-------+-----------+ | Id | Name | Subject | +------+-------+-----------+ | 125 | Raman | Computers | +------+-------+-----------+ 1 row in set (0.00 sec)
The above is the detailed content of How to get specific records from a table as a result set using the MySQL FIND_IN_SET() function?. For more information, please follow other related articles on the PHP Chinese website!