Oracle数据库按正则切割字符串
作者:互联网
1、方法一:
SELECT regexp_substr('161,83,66,81','[0-9]+',1,LEVEL) FROM dual CONNECT BY level <= length('161,83,66,81') - length(regexp_replace('161,83,66,81',',','')) + 1;
另附流程备份如下(注意最后的分号在流程中是否需要):
SELECT ID ,DEPARTMENTID ,LASTNAME FROM HRMRESOURCE WHERE LOGINID IS NOT NULL AND DEPARTMENTID IN (SELECT regexp_substr(t.deptid,'[0-9]+',1,LEVEL) FROM (SELECT (CASE to_char(DEPARTMENTID) WHEN to_char(161) THEN 161||','||81||','||66||','||83 ELSE to_char(DEPARTMENTID) END ) deptid FROM HRMRESOURCE WHERE DEPARTMENTID = 161) t CONNECT BY level <= length(t.deptid) - length(regexp_replace(t.deptid,',','')) + 1) AND LASTNAME NOT LIKE '%离职%';
标签:deptid,数据库,char,正则,DEPARTMENTID,66,Oracle,161,SELECT 来源: https://www.cnblogs.com/suhfj-825/p/11510283.html