Querying all records; include mismatches

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

Guest

Hello-
I am currently trying to compare two tables to one another that have the
same field "Sku Number". The problem I have is that I want to create a new
table from a query that matches up the skus that exist in both tables, but
also include those that do not have a match. As of right now, the query is
only capturing those that match and leaving out those that don't match.

I tried sorting the field in both lists, hoping that it would just leave
those blank that don't have a match but instead, the list comes out unsorted
and without any blanks. I hope this question makes sense :)

Thanks
 
If one table has ALL the "Sku Numbers" and the other has only some of them,
you could do a Left Join. However if both tables are missing some of the "Sku
Number", you can't do it directly.

You can do a UNION query to get a list of all the "Sku Number" from both
tables. It would look something like:

SELECT [Sku Number]
FROM Table1
UNION
SELECT [Sku Number]
FROM Table2);

Another option would be to do a Create Table query with records from one
table. Then pour in the remaining records into the new table from the second
table with an Append query.

This would give you duplicate [Sku Number] records. If you didn't like that,
you could run the Make Table query then open the new table in design view.
Make the [Sku Number] field the primary key (assuming that you don't have
dupes) then run the Append Query. That would only let in records with a
different [Sku Number].
 
Back
Top