Link to home
Start Free TrialLog in
Avatar of zimmer9
zimmer9Flag for United States of America

asked on

How to find the values not present in one table compared to another table in an Access 2003 mdb type file?

I am modifying an Access program using Access 2003 with an MDB type file.

How would you modify the following SQL statement to find the values for field "Bank" in
table tblOpenItems that don't exist in table tblBanks for field [Bank Code]:

SELECT tblBanks.*, tblDates.dtRec, tblOpenItems.*
FROM tblDates, tblBanks INNER JOIN tblOpenItems ON tblBanks.[Bank Code]=tblOpenItems.Bank
WHERE tblOpenItems.t In ("A","D","E");
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image


select tblOpenItems.bank
from tblOpenItems
left join tblOpenItems ON tblBanks.[Bank Code]=tblOpenItems.Bank
where tblBanks.[Bank Code] is null
SELECT tblBanks.*, tblDates.dtRec, tblOpenItems.*
FROM tblDates, tblOpenItems LEFT JOIN tblBanks ON tblBanks.[Banks.[Bank Code]=tblOpenItems..Bank WHERE tblBanks.[Bank Code] is Null
SELECT tblBanks.*, tblDates.dtRec, tblOpenItems.*
FROM tblDates, tblBanks RIGHT JOIN tblOpenItems ON tblBanks.[Bank Code]=tblOpenItems.Bank
WHERE tblBanks.[Bank Code] IS NULL AND tblOpenItems.t In ("A","D","E");
Avatar of zimmer9

ASKER

select tblOpenItems.bank
from tblOpenItems
left join tblOpenItems ON tblBanks.[Bank Code]=tblOpenItems.Bank
where tblBanks.[Bank Code] is null
----------------------------------------
I tried this in Access using a Select query and got the following error:
Syntax error in JOIN operation. (Error 3135)
You entered an SQL statement that has an invalid join operation. It could be an inner join, outer join, or self-join.

Possible causes:

A reserved word or argument name is misspelled or missing.
Punctuation is incorrect.

Avatar of zimmer9

ASKER

SELECT tblBanks.*, tblDates.dtRec, tblOpenItems.*
FROM tblDates, tblBanks RIGHT JOIN tblOpenItems ON tblBanks.[Bank Code]=tblOpenItems.Bank
WHERE tblBanks.[Bank Code] IS NULL AND tblOpenItems.t In ("A","D","E");
---------------------------------------------
I tried this in Access using a Select query and got the following error:

Join expression not supported. (Error 3296)
Possible causes:

Your SQL statement contains multiple joins in which the results of the query can differ, depending on the order in which the joins are performed. You may want to create a separate query to perform the first join, and then include that query in your SQL statement.
The ON statement in your JOIN operation is incomplete or contains too many tables. You may want to put your ON expression in a WHERE clause.


ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zimmer9

ASKER

SELECT tblBanks.*, tblDates.dtRec, tblOpenItems.*
FROM tblDates, tblOpenItems LEFT JOIN tblBanks ON tblBanks.[Banks.[Bank Code]=tblOpenItems..Bank WHERE tblBanks.[Bank Code] is Null
---------------------------------------------
I tried this in Access using a Select query and got the following error:

Join expression not supported. (Error 3296)
Possible causes:

Your SQL statement contains multiple joins in which the results of the query can differ, depending on the order in which the joins are performed. You may want to create a separate query to perform the first join, and then include that query in your SQL statement.
The ON statement in your JOIN operation is incomplete or contains too many tables. You may want to put your ON expression in a WHERE clause.