I want to find duplicate names from my database I wrote the following query. But it is displaying more that existing records. I guess it is taking cartesian product.

select a.name from emp from emp a,emp b where a.name=b.name;

can anyone correct this query.
I want to display all the duplicate records having same names...

for example for the following table. I want to display result having same dname like
DEPTNO DNAME LOC
------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
50 SALES hyd

output should be
30 sales chicago
50 sales hyd

select * from dept where d_name in (select d_name from dept group by d_name having count(d_name)>1 )
select count(deptno), dname
from dept
group by dname
having count(deptno)>1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.