MySQL: FIND_IN_SET() reference
10 September 2023 (Updated 10 September 2023)
The FIND_IN_SET
function lets you find the position of a string within a comma-separated list of strings.
Syntax
FIND_IN_SET(search_string, comma_separated_string)
Example
FIND_IN_SET('a', 'a,b,c') # 1
FIND_IN_SET('b', 'a,b,c') # 2
FIND_IN_SET('d', 'a,b,c') # 0
Note that the function doesn’t used zero-based indexing like most programming languages and that it returns 0
if the string isn’t found.
Tagged:
MySQL
Thanks for your comment 🙏. Once it's approved, it will appear here.
Leave a comment