select distinct * from tablename a
where exists (select 1 from tablename b
where b.id<>a.id and b.name=a.name)
where exists (select 1 from tablename b
where b.id<>a.id and b.name=a.name)
调试欢乐多
如:
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