Skip to content
Advertisement

How to make IN on values from cell?

I have table which contains list of data ceparated by coma eg

deputy
1,2,3
2
4,6

I am trying to left joint it with IN clause, but without success

LEFT JOIN chat_user AS du
    ON du.chat_user_id  IN (message_item.deputy)

Advertisement

Answer

One option uses string functions:

left join chat_user as du
    on ',' || message_item.deputy || ',' like '%,' || du.chat_user_id  || ',%'
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement