SQL如何查询有重复的数据!code   
00001
00001
00002
00003查询结果应该是
00001
00001

解决方案 »

  1.   

    select code from table a where exists (
    select code as a from table where a.code = code group by code having count(*) > 1) order by code
      

  2.   

    你的表只有一个字段吗?
    还是只要这个字段的内容相同就算重复数据?第一种方法:
    select count(*) repeat_nums,name from YOUR_TABLE_NAME group by code  having count(*)>1
    第二种方法:(输入你需要的结果,表有个主键id)select code from YOUR_TABLE_NAMEwhere id in (
    select id from YOUR_TABLE_NAME
      group by codehaving(count(id))>1
    )
      

  3.   

    select * from table_name t1 where 2<=(select count(code) from table_name t2 where(t1.code=t2.code));
      

  4.   

    select code from table 
     where  code in (select code from table group by code having count(code)>1)