只能找到T1表中没有而T2表中有的记录:
YX0102        24449
YD0004        38888
除非:你在T2表中添加一个记录时间的字段或标识字段(id)
或着:等高手...

解决方案 »

  1.   

    又没有刷新...只能找到T1表中没有而T2表中有的记录:
    YX0102        24449
    YD0004        38888
    除非:你在T2表中添加一个记录时间的字段或标识字段(id)
    或着:等高手...
      

  2.   

    select table1 no,table2 no ,hm from table1,table2
    where noexists
    (select no from table1 )
    order by no
      

  3.   

    select t2.no, t2.hm from t2 where t2.hm not in( select t1.hm from t1 where t2.no=t1.no)
      

  4.   

    一定保证是T2比T1多么,如果相同的NO,T1比T2多的话就要用到left/right join了
      

  5.   

    select * from t2
    where not exists (
    select 1 from t1 
    where no=t2.no and hm=t2.hm
    )
    and exists (
    select 1 from t1 
    where no=t2.no
    )
      

  6.   

    如果一定是T2比T1多的话,这么写:
    select t2.no, t2.hm from t2 
    left join t1 
    on t1.no= t2.no and t1.hm=t2.hm 
    where t1.no is null
      

  7.   

    呵呵,你的意思是修改的不包括在内?!
    那可就基本无解了,比如数据是
          t1
          
              no                        hm
              YX0102        45668
              YX0102        45678
              YX0102        48888
          
          t2
          
              no                        hm
              YX0102        45668
              YX0102        45679
              YX0102        48889
    那样你根本不知道是修改了后两条(无结果),还是改了一条,增了一条,删了一条(结果一条),还是......这也是shinebei(灰灰) 一定要问是不是T2比T1多的原因,遗憾的是你未回答他的问题。要我说,以上各位的回答都对!!!
      

  8.   

    要不,只有如 supsuccess(口气不小) 所说:等高手......不过我想,高手也解决不了不清楚的问题!
      

  9.   

    对于一个no,t1,t2中都有,而且在t1或t2中记录不少于一个就行。假如t1中有三条记录,t2中有一条,而且hm不存在t1中,这样的记录也符合查询条件。
      

  10.   

    那举个例子说明一下
    select  *  from  t2
      where  not  exists  (
      select  1  from  t1  
      where  no=t2.no  and  hm=t2.hm
      )
      and  exists  (
      select  1  from  t1  
      where  no=t2.no
      )
      
    怎么结果不对!
      

  11.   

    试着这样看看,如果你不要求在一句话解决问题的话
    把T1和T2插入一张临时表,然后把T1表和这个临时表进行我上面写的那样left join一下:
    select #temp.no, #temp.hm from #temp
    left join T1
    on  #temp.no= t1.no and #temp.hm=t1.hm  
    where t1.no is null
      

  12.   

    Yang_(扬帆破浪) 是的可以用只要再加
    1 < ALL
    (select count(*) from t2 two where t2.no = one.cardno)
      

  13.   

    >>对于一个no,t1,t2中都有,而且在t1或t2中记录不少于一个就行。假如t1中有三
    >>条记录,t2中有一条,而且hm不存在t1中,这样的记录也符合查询条件。
                   ^^>>  1  <    ALL
           ^^
    >>  (select  count(*)  from  t2  two  where  t2.no  =  one.cardno)
    不明白你说什么!!