未测试,重点理解下思路吧 WITH T AS ( select REGEXP_SUBSTR(str, '[^,]+', 1, LEVEL) STR from (select '320000,320100,320200,320300,320400,320500,320600,320700,320800,320900,321000,321100,321200,321300' str from dual) CONNECT BY LEVEL <= REGEXP_COUNT(str, ',') + 1 ) SELECT mid FROM table1 group by mid having sum(case WHEN r_code not in (select str from T) then 1 ELSE 0 END)=0
WITH T AS (
select REGEXP_SUBSTR(str, '[^,]+', 1, LEVEL) STR
from (select '320000,320100,320200,320300,320400,320500,320600,320700,320800,320900,321000,321100,321200,321300' str from dual)
CONNECT BY LEVEL <= REGEXP_COUNT(str, ',') + 1
)
SELECT mid
FROM table1
group by mid
having sum(case WHEN r_code not in (select str from T) then 1 ELSE 0 END)=0