View Full Version : IN criteria/Exists


kilobyte
10-13-2005, 11:44 AM
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.


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.

raskew
10-13-2005, 05:16 PM
Hi -

Give this a try:

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