Use values in one table as criteria in a query

M

Matt D Francis

I have have a table containing just one field (TBL_BBABYDUPES) - a list of
ID's.

I have a second table (PASBABY) containing many fields but also including
the same ID field as the other table, The ID field is unique in each table,
but there are ID's in table 2 not in table 1.

I want to use Table 1 in a Query to EXCLUDE all the records in Table 2 where
the ID also exists in Table 1.

How should I do this?

My current SQL is:

SELECT PASBABY.*
FROM PASBABY, TBL_BBABYDUPES
WHERE (((PASBABY.F_BABYID)<>[TBL_BBABYDUPES].[F_BABYID]));

But this isn't woring - I'm unsure of what is required in joining the two
tables.
 
O

Ofer

Use the query wizard to create an UnMatch record query, so you can exlude all
the records from one table.

Or, you can use something like

Select Table1Name.* From TableName
Where [ID] Not In (Select [ID] From Table2Name)
 
M

Matt D Francis

Great, thank-you. Wizard worked fine, but will try the Select SQL as well for
future reference.

Ofer said:
Use the query wizard to create an UnMatch record query, so you can exlude all
the records from one table.

Or, you can use something like

Select Table1Name.* From TableName
Where [ID] Not In (Select [ID] From Table2Name)

--
\\// Live Long and Prosper \\//
BS"D


Matt D Francis said:
I have have a table containing just one field (TBL_BBABYDUPES) - a list of
ID's.

I have a second table (PASBABY) containing many fields but also including
the same ID field as the other table, The ID field is unique in each table,
but there are ID's in table 2 not in table 1.

I want to use Table 1 in a Query to EXCLUDE all the records in Table 2 where
the ID also exists in Table 1.

How should I do this?

My current SQL is:

SELECT PASBABY.*
FROM PASBABY, TBL_BBABYDUPES
WHERE (((PASBABY.F_BABYID)<>[TBL_BBABYDUPES].[F_BABYID]));

But this isn't woring - I'm unsure of what is required in joining the two
tables.
 
Top