Name

FIND_IN_SET( )

Synopsis

FIND_IN_SET(string, string_list)

This function returns the location of a string given in the first argument of the function, in a comma-separated list in a string given in the second argument. The first element of the list is 1. A 0 is returned if the string is not found in the set. It returns NULL if either argument is NULL.

SELECT FIND_IN_SET('test', 'test,one,two,three')
       AS 'FIND_IN_SET( ) Test';
+---------------------+
| FIELD_IN_SET( ) Test |
+---------------------+
|                   1 |
+---------------------+

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.