I have 2 tables. table_a
is current data, table_b
has updated data. The 1st thing I need to do is move all new records, i.e., move the records from table_a
to table_b
that have a value in a primary index field (primaryField
) not found in table_a
.
I've tried variations of the following:
INSERT INTO table_b (`col1`,`col2`,`col3`,etc...)
VALUES (`col1`,`col2`,`col3`,etc...)
FROM table_a
WHERE table_a.primaryField NOT IN (SELECT table_b.primaryField)
This approach doesn't work. How do you select only the rows in a table that have values for a specific field not found in the matching field of a 2nd table?