I have 2 tables: Persons id = personid Contacts id = contactid personid -> Persons:personid
I need to extract information about persons who have exactly 2 contacts. How it possible? Thanks in advance
coopster
7:28 pm on Apr 20, 2006 (gmt 0)
Use a GROUP BY clause with a HAVING clause:
SELECT Persons.personid FROM Persons INNER JOIN Contacts ON Persons.personid = Contacts.personid GROUP BY Persons.personid HAVING COUNT(Contacts.personid) = 2 ;