有两张表table0(T001,T002,VALUE) table1(W001,W002,VALUE)
table0与table2通过T001=W001和T002=W002进行关联;
我现在想找到table0中的不存在于table1中的记录,请问这条SQL语句怎么写??

解决方案 »

  1.   

    select t.* from table0 t where not exists(select 1 from table1 where t.T001=W001 and t.T002=W002)
      

  2.   

    SELECT *
    FROM table0 AS A
    WHERE NOT EXISTS(
             SELECT *
             FROM table1
             WHERE A.T001=W001
                 AND A.T002=W002
          )
      

  3.   

    1、not exists
    2、except
      

  4.   

    select tb0.*
    from tb0 left join tb1 on tb0.T001=tb1.W001 and tb0.T002=tb1.W002
    where tb2.woo is null
      

  5.   

    select T.* from table0 T where not exists(select 1 from table1 where T.T001=W001 and T.T002=W002)
      

  6.   

    select * from TAble0 where checksum(T001,T002) not in(select checksum(W001,W002) from table1)
      

  7.   


    select m.* from table0 m where not exists (select 1 from table1 n where w001 = m.T001 and w002 = m.T002)
      

  8.   


    select a.* from table0 a 
    where not exists(
    select * from table1 where a.T001=W001 and a.T002=W002)
      

  9.   

    select b.* 
    from  table1 as a right join table0 as b on T001=W001 and T002=W002
      

  10.   

    select m.* from table0 m where not exists (select 1 from table1 n where w001 = m.T001 and w002 = m.T002)--如果t001,t002 , w001,w002不是image,text等字段,可以使用checksum
    select * from table0 where checksum(t001 , t002) not in (select checksum(w001 , w002) from table1)
      

  11.   

    SELECT T001,T002,VALUE
    FROM table0 AS T0
    LEFT OUTER JOIN table1 AS T1
    ON T0.T001 = T1.W001 AND T0.T002 = T1.W002
    WHERE T1.W001 IS NULL AND T1.W002 IS NULL
      

  12.   


    select b.* 
    from  table1 as a right join table0 as b on T001=W001 and T002=W002
    where W001 is null
      

  13.   

    select t.* from table0 t 
    where not exists(select 1 from table1 where t.T001=W001 and t.T002=W002)
      

  14.   

    1.select t.* from table0 t where not exists(select 1 from table1 where t.T001=W001 and t.T002=W002)
    2.也可以用full join 再判断null