[SQL] problem with SELECT and DISTINCT

pawelch

Registered User.
Local time
Today, 06:28
Joined
Jun 10, 2009
Messages
21
Hi all

I have two tables: Person and CompanyContacts. There are multiple Person fk's stored in CompanyContacts. For selecting unique entries of PersonID in CompanyContacts I was trying to do it in the following way:

Code:
Select * FROM  CompanyContacts WHERE CompanyContacts.PersonID IN 
( SELECT DISTINCT CompanyContacts.PersonID FROM CompanyContacts)
However, the result of the query is not unique, even though the part in the brackets results in the unique selection.

Any workaround would be appreciated.

Cheers,

p.
 
The Distinct will select everybody but only once whereas I gather that you want to select those that only appear once, so do a count of personID and select where that is 1

Brian
 

Users who are viewing this thread

Back
Top Bottom