oracle使用in子查询中用到replace函数问题

在oracle数据库中编写sql语句 select * from User where userName in ('a1','a2','a2') 这样是可以查询出结果,但如果使用 select * from User where userName in ( select regexp_replace('''a1#a2#a3''','#',''',''') as tt from dual ) 这样查没有结果 原因暂时认为是in子查询需要传集合,再此先提供解决办法 select t.* from "USER" t where t.UserName in ( select REGEXP_SUBSTR('a1#a2#a3','[^#]+',1,ROWNUM) AS s from dual CONNECT BY ROWNUM<=3) 3为字符串length,字符串短的可以这样处理,长的涉及到效率问题,建议使用pl_table
原文地址:https://www.cnblogs.com/hexiweb/p/2601320.html