FIND_IN_SET Function - How to find position of string in Comma separate values list
FIND_IN_SET function is used to find the position of string in list of comma separated values. FIND_IN_SET can return depending upon the searched value and values present in comma separated list.
Syntax:
FIND_IN_SET( StringtoFind,Comma_Separated_String_List);
- Either StringToFind or Comma_Separated_String_List is null, then output is going to be null for find_in_set.
- Find_IN_Set will return zero if the StringtoFind is not present in Comma_Separated_String_List.
- If StringtoFind is present in Comma_Separated_String_List then positive number will be returned.
Below is example that covers all above scenarios or result set returned by find_in_set.
Select find_in_set('aamir',null),
find_in_set(null,'aamir,shahzad'),
find_in_set('Robert','aamir,shahzad'),
find_in_set('robert','aamir,shahzad,robert,test,test2');
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.