table1 a字段只有一个值   table2的b字段有可能是一个值或多个值表的值:a的值是2   b的值是 2 或 1,2,3  b的多个值之间是用逗号分开
如何知道a的值在b的值内 select 语句如何写 谢谢

解决方案 »

  1.   

    select table2.* from table1,table2
    where instr(','||b||',',','||a||',')>0;
    or
    select table2.* from table1,table2
    where ','||b||',' like '%,'||a||',%';
      

  2.   

    select t1.a,t2.b 
    from table1 t1,table2 t2
    where instr(t2.b,t1.a)>0;
      

  3.   

    njhart2003兄的可能会有问题,如果a的值为2 而 b的值有1,23,34的数据
      

  4.   

    select * from table1,table2
    where table2.b=table1.a(+);当 a 有多条记录的值都满足 b时,以上语句取不到数据.为什么
    table1
    a          b
    -------------
    1          1,2,3
    2
    3