select distinct * from tablename a
where exists (select 1 from tablename b
  where  b.id<>a.id and b.name=a.name)

解决方案 »

  1.   

    假设这个表名为 table, 你可以这么写select distinct A.id, A.name from table A, table B where (A.id <> B.id) and (A.name = B.name);我用过,这没有问题,给分吧
      

  2.   

    哦,错了,表里面有N条相同的记录,要查出来
    如:
    ID    Name
    12     d
    34     e
    543    t
    34     e
    12     d
    45     y
    543    t结果应为:
    ID     Name
    12     d
    12     d
    34     e
    34     e
    543    t
    543    t
      

  3.   

    select id,name from table03 where name in(select name from  table03 group by name having count(name)>1)