id riqi aa 2010.01.01 aa 2010.02.02 bb 2010.01.01 bb 2010.02.02 cc 2010.01.01
tb2
id riqi aa 2010.01.01 bb 2010.01.01 bb 2010.02.02
ÏëÒªµÃµ½µÄ½á¹ûΪ id riqi aa 2010.02.02 cc 2010.01.01
ûÓÐΨһ¼ü 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) 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) 2Â¥Õý½â£¬not exists »»³É not in Ò²Ò»Ñù ÕâλÀÏ¸ç»ØÌûºÃ¿ì¡£¡£¡£¡£¡£¡£ SQL code:
select * from tb1 t1 where not exists(select 1 from tb2 where id=t1.id and riqi=t1.riqi)
ÕâÄêÍ· ÊÖÂýÁ˲»ÐÐ ÏëÒªµÄÊÇ select max(riqi),id from tb1 group by id Õâ¸ö²»ÔÚtb2ÖÐµÄ ÍøËٿ죬»úÆ÷ºÃ£¬ÄÜÁ¦Ç¿¡£ ¶·²»¹ýÄãÃǰ¡¡£¡£¡£¡£55555 ¶¼ºÃ¿ì {{----}