Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Help 1

Status
Not open for further replies.

SmokinRR

Technical User
May 26, 2004
56
0
0
US
Okay, I'll try to lay this out so it makes sense. I am trying to write a query that returns a record, only if another record exists in the table. Here is the table structure for clarification: (bogus data of course...)

AssocID ProdLicensed LicensedDate
34454 2 2/2/2002
34422 8 2/2/2003
32234 14 1/2/2000
34454 14 1/3/1998

I would like to query this table and have it return all the records where the associate ID is licensed in product 2 and product 14. In other words, I don't want all associates licensed in product 2 and all in 14, I want only the ones licensed in both. Does this make sense? Please let me know if I need to clarify further what I'm asking for ;0)

Thanks in advance for the help, it is greatly appreciated.

Jay
 
I hope this will help (or at least get you going in the right direction):

SELECT A.ASSOCID, A.PRODLICENSED, B.PRODLICENSED, A.LECENSEDDATE, B.PRODLICENSEDATE
FROM [TABLENAME] A INNER JOIN [TABLENAME] B
WHERE A.ASSOCID = B.ASSOCID AND A.PRODLICENSED <> B.PRODLICENSED
ORDER BY ASSOCID


Hope that helps!

-Jason
 
Cheers Jason, that wasn't exactly what I had in mind, but it led me down the right track, thanks alot for the tip!

Later

Jason
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top