两张表:
第一张表:
name groupId
11   100101
22   100102
33   100103
44   100104
55   100105
第二张表:
groupIdList               name
;100102;100104;100105;    1
我要实现:
select name from 第一张表 where groupId in (select groupIdList from 第二张表 name=1)
相当于 select name from 第一张表 where groupId in (100102,100104,100105)

解决方案 »

  1.   

    select name
      from table1
     where groupId in
           (select regexp_substr(groupIdList, '[^;]+', 1, rownum)
              from table2
             where name = 1
            connect by rownum <=
                       length(regexp_replace(groupIdList, '[^;]', null)))
      

  2.   

    select a.name
    from TAB_A a,
         TAB_B b
    where b.groupidlist like '%;'||a.gropid||';%'
    and   b.name=1
      

  3.   


    WITH TABA AS (SELECT '11' AS name,  '100101' AS groupId FROM DUAL UNION 
    SELECT '22' AS name,  '100102' AS groupId FROM DUAL UNION 
    SELECT '33' AS name,  '100103' AS groupId FROM DUAL UNION 
    SELECT '44' AS name,  '100104' AS groupId FROM DUAL UNION 
    SELECT '55' AS name,  '100105' AS groupId FROM DUAL ),
    TABB AS  
    (SELECT ';100102;100104;100105;' AS groupIdList, 1 AS NAME FROM DUAL)
    SELECT TABA.* FROM TABA, TABB
    WHERE TABB.NAME = 1
    AND INSTR(TABB.groupIdList, ';' || TABA.GROUPId || ';') > 0
      

  4.   


    ???? 
    select a.name from 第一张表 a ,
    (select groupIdList from 第二张表 name=1) b
    where groupId  = groupIdList