MySQLFIND_IN_SET() Function
Example
Search for "q" within the list of strings:
SELECT FIND_IN_SET("q", "s,q,l");
Try it Yourself »Definition and Usage
The FIND_IN_SET() function returns the position of a string within a list of strings.
Syntax
FIND_IN_SET(string,string_list)
Parameter Values
| Parameter | Description |
|---|---|
| string | Required. The string to search for |
| string_list | Required. The list of string values to be searched (separated by commas) |
Return Values
- Ifstring is not found instring_list, this function returns 0
- Ifstring orstring_list is NULL, this function returns NULL
- Ifstring_list is an empty string (""), this function returns 0
Technical Details
| Works in: | From MySQL 4.0 |
|---|
More Examples
Example
Search for "a" within the list of strings:
SELECT FIND_IN_SET("a", "s,q,l");
Try it Yourself »Example
Search for "q" within the list of strings (string list is NULL):
SELECT FIND_IN_SET("q", null);
Try it Yourself »
