表A字段 t_a, t_b,t_c      a1   a2  a3
      b1   b2  b3
      c1   c2  c3
      d1   d2  d3
-------------------------
表B
字段 t_a,t_b,t_c,t_d,t_e,t_f      a1   a2  a3 a4  a5  a6
      b1   b2  b3 b4  b5  b6
      c1   c2  c3 c4  c5  c6
-------------------------
其中 表B(t_a,t_b,t_c)包含于表A-------------------------现在要查询一个结果
(在表A 中(t_a,t_b,t_c)但不在表B中)用sql语句怎么表示出来

解决方案 »

  1.   

    select *
    from ta a
    where not exists(select 1 from tb  where a.t_a = ta and a.t_b = t_b and a.t_c = t_c)
      

  2.   

    select a.* from a where not exists
    (select 1 from b where a.t_a=b.t_a and a.t_b=b.t_b and a.t_b=b.t_c ) 
      

  3.   

    select a.* from a where not exists (select 1 from b where t_a = a.t_a and t_b = a.t_b and t_c = a.t_c)
      

  4.   

    怎么四楼显示不完全?select a.* from a where not exists (select 1 from b where t_a = a.t_a and t_b = a.t_b and t_c = a.t_c)
      

  5.   

    select
      * 
    from
      tb t 
    where
      not exists(select 1 from tb  where t.t_a = ta and t.t_b = t_b and t.t_c = t_c)
      

  6.   

    非得这样?
    select a.* from a where 
    not exists 
    (select 1 from b where t_a = a.t_a and t_b = a.t_b and t_c = a.t_c)
      

  7.   


    select a.* from a where not exists(select 1 from b where a.t_a=b.t_a and a.t_b=b.t_b and a.t_b=b.t_c )