由两个表
tab_1
ID T1   T2  
1  01   s
2  02   stab_2
d1  d2  d3
01  a  北京
03  e  北京
01  b  上海
02  c  上海查看tab_1时, 想得到如下结果(用tab_2中的d3='上海')
ID T1 T2 
1  b  s
2  c  s谢谢各位兄弟

解决方案 »

  1.   

    select tab_1.ID,tab_2.d2 T1,tab_1.T2 
    from tab_1,tab_2 
    where tab_1.d2(+)='上海' and tab_1.T1(+) =tab_2.d2选择出的T2列是空的
      

  2.   

    select a.id,b.d2,a.t2
    from tab_1 a,tab_2 b
    where a.t1=b.d1
    and b.d3='上海'
      

  3.   

    select a.id,b.d2,a.t2
    from tab_1 a,
         tab_2 b
    where a.t1=b.d1
          and b.d3='上海'
      

  4.   

    select a.id,b.d2 t1,a.t2
           from tbl1 a
           right join
                 (select * from tbl2
                         where t2 = '上海'
                 )b
           on a.t1 = b.d2