我没太懂你的意思,不知是不是这样:
由于 t2 记录的是 t1 的后一个月,因而想找一下增加的 id号。如果我理解正确就看下面代码,否则也不用看了。
 
select * from t2
where id not exists (select id from t1)

解决方案 »

  1.   

    select * from t2
    where exist
    (select 1 from t1 where t1.no = t2.no
    and t1.id <> t2.id)
      

  2.   

    搂上的兄弟得到的结果是不对的。我的意思是
    t1中有记录no=YS1001,id=522226;而t2中有
    no=YS1001,id=522226和no=YS1001,id=36665。后一个记录是2月份新增加的。
    我要找的是t2中YS1001,id=36665这个记录,也就是说同一个no和它对应的id有新增加 。
      

  3.   

    t1
     no      id
     YS1001  522226
     YX1002  546666
    t2
     no      id
     YS1001  522226
     YS1001  311115
     YX1002  546666
    我需要找出t2中YS1001   311115这个记录
      

  4.   

    select * from t2
    where  exists
    (select 1 from t1 where t1.no = t2.no
    and t1.id <> t2.id)