Wednesday, 4 January 2012

MySQL find_in_set function

In MySQL the FIND_IN_SET() returns the position of a string when it present  within a list of strings.

The string list itself is a string contains substrings separated by ‘,’ (comma) character.

The return value 0 when search string does not exist in the string list.

The return value is  NULL if either of the arguments is NULL.

Syntax :

FIND_IN_SET (search string, string list)


Example

SELECT FIND_IN_SET('ank','b,ank,of,monk'); 

Explanation 

 

The above statement finds the search string ‘ank’ at 2nd place within the string list. So it returns 2.

Output

 

MYSQL FIND_IN_SET 

 

 

 

 

See also :

Mysql find_in_set function


No comments:

Post a Comment