T2这张表中相同的jlbh纪录所有字段都相同?
对于相同的jlbh,比如有1,2,3个,你想选择的是哪一条?为什么?

解决方案 »

  1.   

    select * from T1 a ,T2 b
    where a.jlbh=b.jlbh(+) and b.jlbh is not null
      

  2.   

    楼上的不对
    我说清楚点
    比如:T1中jibh为1的只有一条
    T2中jibh为1有两条,如果关联查询的话,
    select a.jlbh from T1 a ,T2 b
    where a.jlbh=b.jlbh
    不用distinct 的话会列出两条jlbh相同的记录,怎样才能只列出一条?
      

  3.   

    这个是我做的例子,不知道满足你的要求吗?SQL> select * from aaa;      COLA       COLB
    ---------- ----------
           111        333
           222        333
           222        444已用时间:  00: 00: 00.01
    SQL> select * from bbb;COLA      COLB            COLC
    --------- --------- ----------
    11        22               111
    11        22               222
    11        22               333
    11        33               333已用时间:  00: 00: 00.00
    SQL> select a.cola,a.colb from aaa a where exists (select 1 from bbb b where a.colb = b.colc);      COLA       COLB
    ---------- ----------
           111        333
           222        333
      

  4.   

    select t.jlbh from T1 t,T2 a where t.jlbh = a.jlbh
    union 
    select a.jlbh from T1 t,T2 a  where t.jlbh = a.jlbh
    有点多,嘿嘿,不过能满足要求
      

  5.   

    select * from T1 a ,T2 b
    where a.jlbh(+)=b.jlbh and a.jlbh is not null
    应该可以了