Please Help: compare values in two columns present in seperate tab

S

sam

Hi All,

How can I compare values in two columns (columns are in different tables) ?
I also want to display the values that dont match in a seperate table.

For eg:

If values in Column1 from Table1 does not match Values in Column1 from
Table2 then display those values in a seperate table

Is there a way to do this?

THanks in advance
 
J

John Spencer

Sounds like a union query of two unmatched values queries.

SELECT ColumnA
, "In Table1 Only" as Source
FROM Table1 LEFT JOIN Table2
ON Table1.ColumnA = Table2.ColumnX
WHERE Table2.ColumnX is NULL

UNION ALL

SELECT Columnx
, "In Table2 Only" as Source
FROM Table2 LEFT JOIN Table2
ON Table2.ColumnX = Table1.ColumnA
WHERE Table1.ColumnA is NULL

You cannot build this type of query in query design view. You can only build
it in SQL view.

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 

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