select col1,col2,col3,col4 from 表 group by col1,col2,col3,col4 having count(*)>1

解决方案 »

  1.   

    select col1,col2,col3,col4 from 表 group by col1,col2,col3,col4 having count(*)>1
      

  2.   

    SELECT col1, col2, col3, col4
    FROM t
    GROUP BY col1, col2, col3, col4
    HAVING COUNT(*) > 1
      

  3.   

    我的方法可能不好,但能查出来有重复的记录!
    select * from t group by 字段1,字段2,字段3,字段4 having count(*)>1
      

  4.   

    select col1,col2,col3,col4 from yourtable group by col1,col2,col3,col4 having count(*)>1
      

  5.   

    select col1,col2,col3,col4 from 表 group by col1,col2,col3,col4 having sum(1)>1
      

  6.   

    select col1,col2,col3,col4 from yourtable 
    group by col1,col2,col3,col4 
    having count(*)>1
    或:
    select * from yourtabel A 
    where (select count(*) from yourtable 
    where col1 = A.col1 
      and col2 = A.col2 
      and col3 = A.col3 
      and col4 = A.col4 ) > 1
      

  7.   

    select * from 表 tem where exists(
    select 1 from 表 group by col1,col2,col3,col4 having sum(1)>1 and col1=tem.col1 and col2=tem.col2
     and col3=tem.col3 and col4=tem.col4)
      

  8.   

    select col1,col2,col3,col4 into #tmp from yourtable group by col1,col2,col3,col4 having count(*)>1
    delete from yourtable where col1=#tmp.col1 and col2=#tmp.col2 and col3=#tmp.col3 and col4=#tmp.col4
    insert into yourtable select distint * from #tmp