Query - Not equal to

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

Guest

Hello all

I have two tables that have employees IDs as key fields. I am trying to create a query to fetch all of the employees IDs that do not match with the employees IDs in other table
How do I do this? Please help

Thank you
 
Hi Annick,

You didn't mention if you want all non-matches from both
sides, or only one. To get the records that don't match
one table from another, insert both tables into the query
builder and join them on ID. But, double click the join
to change it to an outer join. For instance, if you want
to see all of the records for table 1 that do not have
matches in table 2, change the join to say "all records
from table 1 and only those from table 2 where there are
matches". Then, insert all fields that you want from
table 1, and also insert the ID field from table 2.
Finally, enter Is Null as the criteria for the table 2 ID
field.

If you also want to see the records from table 2 that do
not match those in table 1, do the same thing in reverse.

Also, if the structure of both tables is the same, you
can copy the sql text from the second query, go to the
sql view of the first, type UNION ALL on the line below
the end of the sql text, hit enter, then paste the sql
for the second and you will get all non-matches for both
tables in one query. But, the table structures would
have to be the same to do this.

Hope that helps. Post back if you have further questions.

-Ted Allen
-----Original Message-----
Hello all,

I have two tables that have employees IDs as key
fields. I am trying to create a query to fetch all of
the employees IDs that do not match with the employees
IDs in other table.
 
Back
Top