Search code examples
mysql

Mysql find_in_set slash( / ) separator


I have a value of:

1/2
3/4/5
2/3/6

I want to find the value 2 so the result must be:

1/2
2/3/6

I don't want to use LIKE operator. Is there any way to set the separator in FIND_IN_SET function?


Solution

  • You can use like or find_in_set(). Here is one method:

    where find_in_set(2, replace(col, '/', ',')) > 0