Append Unique Records only!

  • Thread starter Thread starter Adam G
  • Start date Start date
A

Adam G

Greetings,

Currently I am working on an application that requires
that everytime a new record is entered, some of its
fields are inserted into another table which already
contains the fields of the existing records from the
first table.

Unfortunately everytime I run the append query it appends
all of the records from the first table on top of the
records already in the second table. This causes
unwanted duplicates to be present in the second table.

I'm wondering if anyone knows how to only insert the
records that are not already in the second table into the
second table?

Keep in mind that none of the record's fields in the
second table are necessarily unique, only the combination
of the three fields will be unique.

Am I asking too much to be able to do this?

Please help,

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

Something like this:

INSERT INTO tableA
SELECT *
FROM tableB As B INNER JOIN tableA As A
ON B.employeeID = a.employeeID
WHERE b.colA <> a.col1
AND b.colB <> a.col2
AND b.colC <> a.col3

The column order for both tables must be the same.

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

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

iQA/AwUBQVG3yYechKqOuFEgEQJQaQCg6r5SyzLFrmJAA6HRh5dhfycPtbsAoI4v
Crg0ScAWNjrhjYOoh/O9uBQB
=KVjL
-----END PGP SIGNATURE-----
 
Back
Top