sajad torkamani
On this page

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

Leave a comment

Your email address will not be published. Required fields are marked *