select * from a,b
where a.type_id=b.ida表中5条记录,其中2条type_id is null这样关联总是查出3条记录我需要把a表中的所有记录都查出来未什么加了+也没用请教大家

解决方案 »

  1.   

     
    select * from a,b 
    where a.type_id(+)=b.id  
      

  2.   

    select * from a,b 
    where a.type_id = b.id(+)  
      

  3.   

    select *
    from a
    left join b
    on a.type_id=b.id
      

  4.   

    select *
    from  a,b
    where
    a.type_id=b.id(+)
      

  5.   

    [code]
    drop table a;
    drop table b;
    create table a(type_id int,type_name varchar2(10));
    insert into a values(1,'test01');
    insert into a values(2,'test02');
    insert into a values(3,'test03');
    insert into a values(4,'test04');
    insert into a values(5,'test05');create table b(id int,description varchar2(10));
    insert into b values(1,'ok');
    insert into b values(2,'error');
    insert into b values(3,'hello');commit;select * from a
    left join b on a.type_id=b.id
    SQL> connect test01/test01;
    已连接。
    SQL> select * from a
      2  left join b on a.type_id=b.id;   TYPE_ID TYPE_NAME          ID DESCRIPTIO
    ---------- ---------- ---------- ----------
             1 test01              1 ok
             2 test02              2 error
             3 test03              3 hello
             5 test05
             4 test04
                                                [/code]
      

  6.   

    drop table a;
    drop table b;
    create table a(type_id int,type_name varchar2(10));
    insert into a values(1,'test01');
    insert into a values(2,'test02');
    insert into a values(3,'test03');
    insert into a values(4,'test04');
    insert into a values(5,'test05');create table b(id int,description varchar2(10));
    insert into b values(1,'ok');
    insert into b values(2,'error');
    insert into b values(3,'hello');commit;SQL> connect test01/test01;
    已连接。
    SQL> select * from a
      2  left join b on a.type_id=b.id;   TYPE_ID TYPE_NAME          ID DESCRIPTIO
    ---------- ---------- ---------- ----------
             1 test01              1 ok
             2 test02              2 error
             3 test03              3 hello
             5 test05
             4 test04
      

  7.   

    为什么+,left join都没用,难道我关联的表态多了?有10多个表。