Jump to: navigation, search

Mysql FIND IN SET

From w3cyberlearnings

Contents

MySQL FIND_IN_SET Function

This function returns an index of a string that it is in the list.

Syntax FIND_IN_SET

  • str is a string to find
  • strlist is a list of substring separated by ',' characters.
FIND_IN_SET (str, strlist);

Return

Returns a string index when found, and otherwise return 0.

Example 1

mysql> SELECT FIND_IN_SET('girl','dog,cat,man,boy,girl');
+--------------------------------------------+
| FIND_IN_SET('girl','dog,cat,man,boy,girl') |
+--------------------------------------------+
|                                          5 | 
+--------------------------------------------+
1 row in set (0.00 sec)


Example 2

Nothing has found!


mysql> SELECT FIND_IN_SET('tiger','lovely day,hot,extreme');
+-----------------------------------------------+
| FIND_IN_SET('tiger','lovely day,hot,extreme') |
+-----------------------------------------------+
|                                             0 | 
+-----------------------------------------------+
1 row in set (0.00 sec)

Related Links


Navigation
Web
SQL
MISC
References