Select * from 表a where 关键字 not in (select 关键字 from 表b)

解决方案 »

  1.   

    Select * from 表a where 主键 not in (select 主键 from 表b)
      

  2.   

    sql语句高手帮帮忙,我想找出表结构一样的两个表中,一个表有一个表没有的记录。
    1。如果这两个表没有主键怎么做?
    2。如果这两个表有两个以上的主键怎么做?
    希望能一句话实现,谢谢
      

  3.   

    table1-table2:select * from table1 where not exists(select 1 from table2 where table1.列1=table2.列1 and table1.列2=table2.列2 and table1.列3=table2.列3,...,table1.列n=table2.列n)
      

  4.   

    Select * from 表a where 主键 exists (select 1 from 表b where 主键<>表a.主键)
      

  5.   

    agree:
    select * from table1 where not exists(select 1 from table2 where table1.列1=table2.列1 and table1.列2=table2.列2 and table1.列3=table2.列3,...,table1.列n=table2.列n)1。如果这两个表没有主键怎么做?
    select * from table1 where not exists(select 1 from table2 where table1.列1=table2.列1 and table1.列2=table2.列2 and table1.列3=table2.列3,...,table1.列n=table2.列n)2。如果这两个表有两个以上的主键怎么做?
    select * from table1 where not exists(select 1 from table2 where table1.列1=table2.列1 and table1.列2=table2.列2 and table1.列3=table2.列3,...,table1.列n=table2.列n)