oracle查询结果字符串用于查询条件in中,查不到数据,例如:
1、select a.remark from test1 a where 1=1
2、select ”” || REPLACE(a.remark , ‘,’, ”’,”’) || ”” from test1 a
3、select * from test2 b where b.id in (select ”” || REPLACE(a.remark , ‘,’, ”’,”’) || ”” from test1 a
)
4、select * from test2 b where b.id in (‘a’,’b’,’c’,’d’,’e’)
结论:使用1查询出结果为 a,b,c,d,e
使用2查询结果为 ‘a’,’b’,’c’,’d’,’e’
使用3查询不到结果
使用4查询到结果
通过查询资料发现其他方法
select *
from test2 b where
INSTR(‘,’|| (select a.remark
from test1 a ) || ‘,’ , ‘,’ || b.id ||’,’ )>0;
可以查询出结果了