select * from table a, table b
where a.col2=b.col2 and a.col3=b.col3 and a.col4=b.col4
and a.col1<>b.col1查找某字段值重复记录
select * from table1 a, table1 b
where a.A<> b.A and a.C=b.C
其中A为主键,C为要查找重复的字段例如下表:tablename
P_code   C_code      nameselect * from tablename a tablename b
where a.P_code<>b.P_code and a. C_code<>b.C_code and a.name=b.name

解决方案 »

  1.   

    或者用:
    select * from tb a
    where cast(col2 as varchar)+'-'+cast(col3 as varchar)+'-'+cast(col4 as varchar)
    in (select cast(col2 as varchar)+'-'+cast(col3 as varchar)+'-'+cast(col4 as varchar) from tb where a.col1<>col1)
      

  2.   

    select * from  table where col2+','+col3+','+col4 in (
      select col2+','+col3+','+col4 from table 
    group by col2,col3,col4 
    having count(*)>1)