如何从2个链接表中查找重复项?

时间:2014-02-10 04:58:29

标签: mysql

Table 1 : Contacts
Fields : id | first_name | last_name

Table 2 : email (it contains contact_id of contacts table)
Fields : id | contact_id | email_address

我需要根据first_namelast_nameemail_address找到重复的联系人。

1 个答案:

答案 0 :(得分:0)

试试这个

SELECT R.first_name , R.last_name, S.email_address 
FROM Table1 R
INNER JOIN Table2 S ON R.id = S.Contactid
Group By R.first_name , R.last_name, S.email_address
Having Count(S.Contactid)>1;