两张表tb1id       riqi
aa      2010.01.01
aa      2010.02.02
bb      2010.01.01
bb      2010.02.02
cc      2010.01.01tb2id       riqi
aa      2010.01.01 
bb      2010.01.01
bb      2010.02.02想要得到的结果为 
id       riqi   
aa      2010.02.02
cc      2010.01.01

解决方案 »

  1.   

    select * from tb1 where (id+cast(riqi as varchar)) not exists (select (rd+ cast(riqi as varchar)) ss from tb2)
      

  2.   

    select * from tb1 where (id+cast(riqi as varchar)) not in (select (rd+ cast(riqi as varchar)) ss from tb2)
      

  3.   

    select * from tb1 where (id+cast(riqi as varchar)) not exists (select (rd+ cast(riqi as varchar)) ss from tb2)===>
    select * from tb1 where (id+cast(riqi as varchar)) not in (select (rd+ cast(riqi as varchar)) ss from tb2)
      

  4.   

    2楼正解,not exists 换成 not in 也一样
      

  5.   


    select * from tb1 t1 where not exists(select 1 from tb2 where id=t1.id and riqi=t1.riqi)
      

  6.   

    想要的是  select max(riqi),id from tb1 group by id 这个不在tb2中的
      

  7.   


    select id,max(riqi) from (select * from tb1 t1 where not exists(select 1 from tb2 where id=t1.id and riqi=t1.riqi))t group by t.id 
      

  8.   


    (id+cast(riqi as varchar))  这是啥意思  不懂  给讲讲呗  
      

  9.   


    这是把riqi转换成字符串形式,其实这里完全不需要,你数据库里头riqi本身就是字符串的