select * from tablename AA inner join tablename BB on (AA.A=BB.A and AA.B=BB.B)

解决方案 »

  1.   

    select a,b from 表名 group by a,b having count(a)>1
      

  2.   

    select * from A,B where A.a=B.a and a.B=b.B
      

  3.   

    一个数据表中,可能有N条记录,其中有R1和R2两条记录select *  from  Table where A=B
      

  4.   

    select * from 
    tablename a
    inner join tablename b 
    on (a.a=b.a and a.b=b.a)
      

  5.   

    To: hsj20041004(光芒)
    这样子不行的,会得到该表所有的字段。
    如果有主键字段的话,在ON后加上AA.Id<>BB.Id是可以的。
      

  6.   

    有点不明白,我现在并不知道r1.a和r2.a是多少(r1,r2是表中两条记录),我只知道r1.a=r2.a且r1.b=r2.b,我如何写出r1.a=r2.a and r1.b=r2.b?
      

  7.   

    楼主是不是想这个结果:
    create table #test
    (a int ,b int, c int)insert into #test 
    select 1,2,3 union 
    select 1,2,4 union
    select 2,3,4select k.a,k.b,k.c from #test k, 
    (
    select a,b,count(*) as zj from #test group by a,b 
    )jwhere k.a=j.a and k.b=j.b and j.zj=2a           b           c           
    ----------- ----------- ----------- 
    1           2           3
    1           2           4(所影响的行数为 2 行)