Im sure this is easy....

P

Pommy_g

Hi, can anyone help me with this prb

ive got 2 tables, A and B, which are related, table B contains records from table A.


Now i need a query to display the records from table A that are NOT in table B.



Thanks in Advance
 
R

Rick Brandt

Pommy_g said:
Hi, can anyone help me with this prb

ive got 2 tables, A and B, which are related, table B contains records from table A.

Now i need a query to display the records from table A that are NOT in table B.

SELECT * FROM TableA
LEFT JOIN TableB ON TableA.KeyField = TableB.KeyField
WHERE TableB.KeyField Is Null
 
R

Rick Brandt

Pommy_g said:
"Rick Brandt" <[email protected]> wrote in message
from table
A. table B.

thanks for reply

not too sure if i understand that fully though, am i correct in thinking:
/ SELECT * FROM TableA
relationship type-[
\LEFT JOIN TableB ON TableA.KeyField = TableB.KeyField

query criteria - WHERE TableB.KeyField Is Null

Open a new query, select no tables and then switch to SQL view. Paste my
example SQL exactly and then replace the KeyField and TableNames with the
appropriate entries for your tables. Switch to design view to see what this
looks like in the query design grid.
 
P

Pommy_g

whenever i try to save it it comes up with this:
"Syntax error (missing operator) in query expression table A.keyfield
= Table B.Key field'

? do both fields have to be primray key or something?

appreciate the help


Rick Brandt said:
Pommy_g said:
"Rick Brandt" <[email protected]> wrote in message
from table
A.
Now i need a query to display the records from table A that are NOT in table B.

thanks for reply

not too sure if i understand that fully though, am i correct in thinking:
/ SELECT * FROM TableA
relationship type-[
\LEFT JOIN TableB ON TableA.KeyField = TableB.KeyField

query criteria - WHERE TableB.KeyField Is Null

Open a new query, select no tables and then switch to SQL view. Paste my
example SQL exactly and then replace the KeyField and TableNames with the
appropriate entries for your tables. Switch to design view to see what this
looks like in the query design grid.
 
R

Rick Brandt

Pommy_g said:
whenever i try to save it it comes up with this:
"Syntax error (missing operator) in query expression table A.keyfield
= Table B.Key field'

? do both fields have to be primray key or something?

If your table names have spaces in them (a poor practice) then they need to be
enclosed in brackets.

EX: [table A].keyfield
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top