FIND_IN_SET() FUNCTION
The MySQL FIND_IN_SET function is used to get the position of a string in a comma-delimited string list. The various versions of MySQL support the FIND_IN_SET function, namely, MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1, MySQL 4.0 and MySQL 3.23.
Syntax:
FIND_IN_SET( string, string_list )
Parameters:
string: It is used to specify the string to search.
string_list: It is used to specify the strings to be searched.
Example 1:
mysql> SELECT FIND_IN_SET ( ‘O’, ‘J,K,L,M,N,O,P,Q,R,S,T’ );
Output:
6
Explanation:
The string’s position is returned.
Example 2:
mysql> SELECT FIND_IN_SET ( ‘o’, ‘J,K,L,M,N,O,P,Q,R,S,T’ );
Output:
6
Explanation:
The string’s position is returned.