看你的数据库是怎么定义的。如果是以ID为准:select * from mytable where count(id)>1如果以name为准,则:select * from mytable where count(name)>1如果以name和id为准就麻烦点。

解决方案 »

  1.   

    select distinct * from table
      

  2.   

    select …… having …… group by ……
    自己试试看。
      

  3.   


    select id,name from table group by id,name having count(id)>1
      

  4.   

    select  * from  table where id in (select min(id) from table gorup  by name)
      

  5.   

    select distinct  * from mytable where count(id)>1
      

  6.   

    select distinct  * from mytable where count(id)>1
      

  7.   

    --tryCreate table Test(id int,name char(8))
    insert into  test select 1,'zhou'
    union all   select 2,'wu'
    union all   select 2,'wu'
    union all   select 3,'zheng'
    union all   select 3,'zheng'select id,name from test group by id,name having count(id)>1id          name     
    ----------- -------- 
    2           wu      
    3           zheng   (所影响的行数为 2 行)
      

  8.   

    select * from tablename
    where id in
    (
    select id from tablename
    group id 
    having count(*)>=2
    ) B