I need to get the supplier name and their supplier contact if they have the duplicate email address.
The following are the three tables: supplier, username and contact
I have the following query to get the duplicate supplier_id and email address but how can I modify the query to include the contact.first_name and contact.last_name.
select s.supplier_id , c.email from supplier s, username u, contact c
where s.supplier_id = u.supplier_id and
u.contact_contact_id = c.contact_id
group by s.supplier_id, c.email
having count(*) >1
select supplier_id
,t1.contact_id
,t1.first_name
,t1.last_name
from username
,(select distinct contact_id, first_name, last_name
from contact
where contact_id in (select distinct contact_id
from contact
group by email
having count(*) > 1)) t1
where t1.contact_id=username.contact_id;
Bookmarks