IN criteria/Exists

kilobyte

Registered User.
Local time
Today, 10:51
Joined
Oct 5, 2005
Messages
52
I need to make a query that only selects data that is in another query/table.

I have tried to do this using a query with IN criteria as follows.

Code:
SELECT fldOne,fldTwo,fldThree,
FROM tblOne
WHERE (((tblOne.fldOne) In (Select fldOne from tblTwo)) AND ((tblOne.fldTwo) In (Select fldTwo from tblTwo));

But that isn't working. Any ideas as to why?

I think that the answer might be using the EXISTS reserved word, but I don't know how.
 
Hi -

Give this a try:
Code:
SELECT
    tblOne.fldOne
  , tblOne.fldTwo
  , tblOne.fldThree
FROM
   tblOne 
LEFT JOIN
   tblTwo 
ON
   (tblOne.fldTwo = tblTwo.fldTwo) 
AND
   (tblOne.fldOne = tblTwo.fldOne)
WHERE
   ((Not (tblTwo.fldOne) Is Null) 
AND
   (Not (tblTwo.fldTwo) Is Null));

Tested in A97

HTH - Bob
 

Users who are viewing this thread

Back
Top Bottom