How can we use find_in_set() function with multiple search string in mysql?

 

Below multiple search is desired

find_in_set('1,3', '1,2,3,4')


In MySQL find_in_set() would not be able to perform multiple search. Below trick can be followed to achive the same:

If the requirement is to find all the records having 1,3 below code snippet will work:

CONCAT(',', tags, ',') REGEXP ',(1,3),'

Whereas if the requirement is to find all the records having either 1 or 3 below code snippet will work:

CONCAT(',', tags, ',') REGEXP ',(1|39),'

 


Related #tags:     #mysql     #sql    

Related questions




Looking for change? Click below to prepare for technical interview.


Technical Interview Questions