select nodeid from roles
where roleid in (select roleid from employees where username='你好')

解决方案 »

  1.   

    select a.* from roles a,(select roleid||',' roleid from employees where username='你好') b
    where instr(b.roleid,a.roleid||',')>0;
      

  2.   

    select nodeid from roles where   '('||roleid||',' in (select '('||roleid||')' from employees where username='你好')
         or
      ','||roleid||')' in (select '('||roleid||')' from employees where username='你好')
         or
      ','||roleid||',' in (select '('||roleid||')' from employees where username='你好')
      

  3.   

    SQL> select * from employees;USER ROLEI
    ---- -----
    你好 2,3,4SQL> select * from roles;    ROLEID NODEI
    ---------- -----
             1 00110
             2 10010
             3 11100
             4 01100SQL> select a.* from roles a,(select roleid||',' roleid from employees where username='你好') b
      2  where instr(b.roleid,a.roleid||',')>0;    ROLEID NODEI
    ---------- -----
             2 10010
             3 11100
             4 01100SQL>
      

  4.   

    楼上的有问题,容易把部分包含的也找出来,例如username='你好' 的roleid=12,13roles包含roleid=2,3,12,13的纪录,则把这4条的nodeid都找出来了。
    上面还可以简化一些:select nodeid from roles where   '('||roleid||',' in (select '('||roleid from employees where username='你好')
         or
      ','||roleid||')' in (select roleid||')' from employees where username='你好')
         or
      ','||roleid||',' in (select roleid from employees where username='你好')
      

  5.   

    select a.* from roles a,(select ','||roleid||',' roleid from employees where username='你好') b
    where instr(b.roleid,','||a.roleid||',')>0;这样行了
      

  6.   

    ORARichard(没钱的日子......) ,呀,答对了!哈哈!
      

  7.   

    select * from roles where roleid in(select roleid from employee  where name='nihao')