查询表2在表1里没有的数据SQL该如何写呀。谢谢。

解决方案 »

  1.   

    select id form table2 where id not in(select id form table1)
      

  2.   

    假设两个表的关联字段是id,楼上的是一种方法,还可以这样
    select * from table2 a where exist select id from table1 where id = a.id
      

  3.   

    看错了,是不等
    select * from table2 a where exist select id from table1 where id <> a.id
      

  4.   

    SELECT * FROM TABLE2 WHERE ID NOT IN (SELECT ID FROM TABLE1)
      

  5.   

    Select 后面不管是不是需要都带个*是个很不好的习惯