Selecting Distict??

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

In the following SQL, dbo_ContactSoftware & dbo_ContactSpecial are
left joined to dbo_CustomerContact so that I see all contacts, and
only 'special' & 'software' that match.

dbo_ContactSoftware can contain multiple matches to a give
dbo_CustomerContact if the contact has more than one 'software'
selected.
The same can be true of dbo_ContactSpecial.

Can someone tell me how to word this so that for a given contact, I
only ever receive ONE dbo_CustomerContact even if multiple matches for
that contact are found in BOTH dbo_ContactSoftware &
dbo_ContactSpecial.

I will sometimes use the query to show me all users that have software
matches x or y or z AND special matches a or b or c, but would only
want one contact regardless of how many of those match to a contact.

SELECT queCustomer_RLDSegment.*, dbo_ContactSoftware.Software_ID,
dbo_ContactSpecialList.List_ID
FROM ((queCustomer_RLDSegment INNER JOIN dbo_CustomerContact ON
queCustomer_RLDSegment.Customer_ID = dbo_CustomerContact.Customer_ID)
LEFT JOIN dbo_ContactSoftware ON
dbo_CustomerContact.CustomerContact_ID =
dbo_ContactSoftware.CustomerContact_ID) LEFT JOIN
dbo_ContactSpecialList ON dbo_CustomerContact.CustomerContact_ID =
dbo_ContactSpecialList.CustomerContact_ID;

Thanks for any direction!!
 
Tim,
Just select one field from CustomerContact (ie. the index) and do a select
Distinct. If you then need more fields for those customers, do a second query
with the results of the first.
 
Back
Top