MySQL FIND_IN_SET Usage Guide
The FIND_IN_SET function in MySQL is used to search for a value in a comma-separated string list and return its index position in the list. The syntax of this function is as follows:
FIND_IN_SET(search_value, string_list)
search_value is the value to be searched for, and string_list is a comma-separated list of strings.
For example, let’s say we have a table called students, with a field called grades that stores the grades of each student. The data is as follows:
We can use the FIND_IN_SET function to search for students with a grade of 85.
SELECT * FROM students WHERE FIND_IN_SET('85', grades) > 0;
Running the above query will return Bob’s record because it contains a grade of 85.