I am not sure if my question makes sense but I will try to explain here. I have two tables
TABLE SAM (SR PK,CODE)
. Column CODE
may or may not contain comma separated values.
TABLE FOO (CODE_VAL PK, CODE_DISP_TX)
I want to write a select query to give me following output from FOO WHERE SAM.SR = 3
Fix your data model! Storing lists as strings is a really, really bad idea.
Sometimes, we are stuck with other people's really, really bad decisions. You can do:
select f.*
from foo f
where exists (select 1
from sam s
where ',' || code || ',' like '%,' || f.code || ',%'
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.