Use values in one table as criteria in a query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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)
 
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.
 

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

Back
Top