Access SQL Append statement where values in three field must be unique

Murray Brown
Murray Brown used Ask the Experts™
on
Hi

I have two tables each with the same structure: Col1, Col2 and Col3 as fields.
I want to append all values from Table1 to Table2 except records that already ahve the same data in all three columns. So all records in Table2 are unique
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT Security Analyst Senior
Commented:
So..  Do you mean something like the following?

INSERT INTO TABLE2
SET Table2.Col1 = Table1.Col1,
Table2.Col2 = Table1.Col2,
Table2.Col3 = Table1.Col3
WHERE NOT IN Table1.Col1(SELECT Col1 FROM Table2)
AND NOT IN Table1.Col2(SELECT Col2 FROM Table2)
AND NOT IN Table1.Col3(SELECT Col3 FROM Table2)

Open in new window


HTH,

Kent
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
Thanks. Exactly what I need
Murray BrownASP.net/VBA/VSTO Developer

Author

Commented:
Hi. I got a syntax error on the SET

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial