compare tables

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

Guest

hi,
I have 2 tables I want to develop a comparison query for. i want the output
to be like this:

3 columns:
acct# intable1? intable2?


so the query should pull all account numbers from both tables, but the
output should be listed in 3 columns as above. i want to see if an account
number is in both tables, and if not, in which table?

thanks in advance,
geebee
 
geebee said:
hi,
I have 2 tables I want to develop a comparison query for. i want the output
to be like this:

3 columns:
acct# intable1? intable2?


so the query should pull all account numbers from both tables, but the
output should be listed in 3 columns as above. i want to see if an account
number is in both tables, and if not, in which table?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Just use 2 queries:

What acct_nbrs are in table1 and NOT in table2?

SELECT table1.acct_nbr
FROM table1 LEFT JOIN table2 ON table1.acct_nbr = table2.acct_nbr
WHERE table2.acct_nbr IS NULL


What acct_nbrs are in table2 and NOT in table1?

SELECT table2.acct_nbr
FROM table2 LEFT JOIN table1 ON table1.acct_nbr = table2.acct_nbr
WHERE table1.acct_nbr IS NULL

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRFkQ2YechKqOuFEgEQL5QwCgjrvyDIZsD/UgEQp5wfE6qFLomVYAnAuU
C+DKxde6X3T5CBQpbT/WKBPV
=JcKu
-----END PGP SIGNATURE-----
 
Back
Top