R
Rajesh B. Patel
Hi All,
I cannot get a query with the Exists function to work properly. Using
the In function gives the proper results, but it runs too slowly. The
queries are as follows:
(Exists function version)
SELECT tbl_Keywords.* FROM tbl_Keywords
WHERE EXISTS (Select qry_Keywords_By_Participant.KeywordID FROM
qry_Keywords_By_Participant WHERE
tbl_Keywords.KeywordID=qry_Keywords_By_Participant.KeywordID);
(In function version)
SELECT tbl_Keywords.*
FROM tbl_Keywords
WHERE (((tbl_Keywords.KeywordID) In (Select
qry_Keywords_By_Participant.KeywordID FROM qry_Keywords_By_Participant)));
The overall goal of the query is to select all records in tbl_Keywords
that have a corresponding KeywordID in the qry_Keywords_By_Participant
query. Since tbl_Keywords is a superset of qry_Keywords_By_Participant I
should get all the records in qry_Keywords_By_Participant in my results.
When I run the Exists function version I get ALL the records in
tbl_Keywords. When I run the In function version I get the expected results.
A quick experiment in which I created a table from the results of
qry_Keywords_By_Participant and then used the table in place of the
query in the Exists function version produced the correct results.
Any ideas why?
Thanks so much.
raj
I cannot get a query with the Exists function to work properly. Using
the In function gives the proper results, but it runs too slowly. The
queries are as follows:
(Exists function version)
SELECT tbl_Keywords.* FROM tbl_Keywords
WHERE EXISTS (Select qry_Keywords_By_Participant.KeywordID FROM
qry_Keywords_By_Participant WHERE
tbl_Keywords.KeywordID=qry_Keywords_By_Participant.KeywordID);
(In function version)
SELECT tbl_Keywords.*
FROM tbl_Keywords
WHERE (((tbl_Keywords.KeywordID) In (Select
qry_Keywords_By_Participant.KeywordID FROM qry_Keywords_By_Participant)));
The overall goal of the query is to select all records in tbl_Keywords
that have a corresponding KeywordID in the qry_Keywords_By_Participant
query. Since tbl_Keywords is a superset of qry_Keywords_By_Participant I
should get all the records in qry_Keywords_By_Participant in my results.
When I run the Exists function version I get ALL the records in
tbl_Keywords. When I run the In function version I get the expected results.
A quick experiment in which I created a table from the results of
qry_Keywords_By_Participant and then used the table in place of the
query in the Exists function version produced the correct results.
Any ideas why?
Thanks so much.
raj