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 <=