比如我有表1,表2,表3,三个表都有一个共同的字段phonenumber,我现在要通过这个字段,把表一中的数据查出来,而且是关联表2,和表3的,也就是左连接表2,左连接表3,可是如何写?
谢谢

解决方案 »

  1.   

    select t1.* from t1,t2,t3 where t1.phonenumber=t2.phonenumber(+) and t1.phonenumber=t3.phonenumber(+)
      

  2.   

    我是想把t1做左连接,比如两个表
    SELECT * FROM TABLE1,TABLE2
    WHERE TABLE1.PHONENUMBER(+)=TABLE2.PHONENUMBER AND TABLE1.be='200501'
    我现在想把TABLE3也连接进来
      

  3.   

    select t1.* from t1,t2,t3 where t1.phonenumber=t2.phonenumber(+) and t1.phonenumber=t3.phonenumber(+) and t1.be='200501'
    有什么问题?
      

  4.   

    SQL> desc test
    Name Type   Nullable Default Comments 
    ---- ------ -------- ------- -------- 
    ID   NUMBER Y                         
    T1   NUMBER Y                         
    T2   NUMBER Y                         
    T3   NUMBER Y                         
    T4   NUMBER Y                         
    T5   NUMBER Y                         SQL> desc test1
    Name Type   Nullable Default Comments 
    ---- ------ -------- ------- -------- 
    ID   NUMBER Y                         SQL> desc test2
    Name Type   Nullable Default Comments 
    ---- ------ -------- ------- -------- 
    ID   NUMBER Y                         SQL> select t.* from test t, test1 t1,test2 t2 where t.id=t1.id(+) and t.id=t2.id(+);        ID         T1         T2         T3         T4         T5
    ---------- ---------- ---------- ---------- ---------- ----------
             1          5          6          1          2          4
             2          4          7          1          5          9
    SQL> select t.*,t1.id t1_id,t2.id t2_id from test t, test1 t1,test2 t2 where t.id=t1.id(+) and t.id=t2.id(+);        ID         T1         T2         T3         T4         T5      T1_ID      T2_ID
    ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
             1          5          6          1          2          4            
             2          4          7          1          5          9            
    你要哪个?
      

  5.   

    是不是这样写?
    select * from (t1 left join t2 on t1.mdn=t2.mdn)
    left join t3 on t1.mdn=t3.mdn
      

  6.   

    select t1.* from t1,t2,t3 where t1.phonenumber=t2.phonenumber(+) and t1.phonenumber=t3.phonenumber(+)