mysql FIND_IN_SET equivalent to postgresql

selva picture selva · Feb 3, 2016 · Viewed 8.7k times · Source
select * 
from folder f,uploads u 
where u.id=f.folderId 
and FIND_IN_SET('8', '15,9,13,27')

Please tell to me equivalent to predefind or userdefined postgresql function

Answer

a_horse_with_no_name picture a_horse_with_no_name · Feb 3, 2016

You shouldn't be storing comma separated values in the first place, but you can do something like this:

select * 
from folder f
  join uploads u ON u.id = f.folderId 
where '8' = ANY (string_to_array(some_column,','))

string_to_array() converts a string into a real array based on the passed delimiter