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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query to Select on 2 "one to many" relates

Status
Not open for further replies.

gwoman

Programmer
Nov 16, 2004
199
US
Hi ...

I have 3 tables X, Y, & Z ..
TableX & TableY have 1 to many relates to TableZ (X>>Z<<Y) however they are not directly related to each other...
I am trying to create a query thats selects all records from TableX where TableX_ID is NOT in TableZ & where TableY_ID = 1 from TableZ;
I can't seem to get the desired results ...
Thanks in advance for any help!

gwoman
 
Your info is a bit sketchy but try something like
Code:
Select X.ID From TableX As X

Where X.ID NOT IN
      (Select Z.ID 
       From TableZ As Z INNER JOIN TableY As Y
            ON Z.CommonField = Y.CommonField
       Where Y.ID = 1)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top