What is "mysql-find-in-set"
Mysql FIND_IN_SET(str, strlist)
is a string function that returns the position of the string to search for str
inside the string list strlist
.
The string list itself is a string that contains several substrings separated by a ‘,’
(comma).
This function returns 0 when the string to find does not exist in the string list and returns NULL if any of the arguments is NULL.
Mysql FIND_IN_SET() (English)
Syntax
FIND_IN_SET(string_a_procurar, lista_de_strings)
Arguments
string_a_search: the string that should be located in the list as the second argument.
list_de_strings: list of strings where the query takes place to verify whether the string passed as the first argument exists.
Example
The following Mysql statement finds the string 'bubu'
in the second position of the string list, returning 2.
Code
SELECT FIND_IN_SET('bubu','b,bubu,of,dragon');
Output
2