- 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 MySQL FIND_IN_SET() function be used to get the particular record(s) from the table as a result set?
We can get the record(s) as a result set by providing the particular string and name of the column as arguments of FIND_IN_SET() function. We also need to use WHERE clause with FIND_IN_SET() function. To understand it, we are using the data, given as below, from table ‘student_info’:
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, following query will use FIND_IN_SET() function to get particular records as result set having the name of the student as ‘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)
Advertisements