Append Query SQL

  • Thread starter Thread starter Eric G
  • Start date Start date
E

Eric G

I wonder if someone can help me out with a simple problem.

I have two tables, let's call them Table-A and Table-B.
They both have the same field names/structure:

Field1, Field2, Field3, Field4, Field,5, Field6

I'd like to append to Table-A all records in Table-B such that
Table-A.Field1 does not equal Table-B.Field1
AND Table-A.Field2 does not equal Table-B.Field2.

That is, both conditions must be met before a record can be appended.

TIA Eric
 
Hi,


Make a backup. Try:

INSERT INTO tableb(f1, f2, f3, f4, f5)
SELECT tablea.f1, tablea.f2, tablea.f3, tablea.f4, tablea.f5
FROM tablea LEFT JOIN tableb
ON tablea.f1 = tableb.f1 AND tablea.f2=tableb.f2
WHERE tableb.f1 IS NULL



In fact, the SELECT portion (the query, without the first line) should
return the records in tablea not in tableb, accordingly to your criteria.




Hoping it may help,
Vanderghast, Access MVP
 
Back
Top