select * from table2 where not exists(select 1 from table1 where id=table2.id)

解决方案 »

  1.   

    select * from table2 where not exists(select 1 from table1 where table1.id=table2.id)
      

  2.   

    结构是怎样的? 

      select * from table2 where id not in 
       (select id from table1)
      

  3.   

    select * from table 1 where checksum(*) not in (select checksum(*) from 表2)
      

  4.   

    select * from table1 where checksum(*) not in (select checksum(*) from talbe2)
      

  5.   

    select * from table2 where id not in 
       (select id from table1)
      

  6.   

    --创建两个结构相同的表
    create table test1
    (tid int,tname varchar(10))
     go
    create table test2
    (tid int,tname varchar(10))
    go
    --插入一些相同的数据
    declare @i int
    set @i = 1
    while @i<10 
    begin 
    insert into test1 (tid,tname) values(@i,@i*2)
    insert into test2 (tid,tname) values(@i,@i*2)
    set @i=@i+1
    end 
    --在表test2中加入一个不同的值
    insert into test2 (tid,tname) values(100,'不同的值')
    --查找test2中不同于test1的值
    select * from test2 where test2.tid not in (select tid from test1)
      

  7.   

    我将分数平均分了,其中有个帖子没给SQL语句只给了2分,其实我也想给8分,但那样结帖分数不对,不能结,多包涵