Chris Peachment <[EMAIL PROTECTED]>
wrote:
I have a database with more than 200,000 records in the
core table. An update table of similar record count contains
a proper subset of the core table columns.

I'm looking for a fast method of merging the values in the
two tables such that :

1. core table columns are updated, and
2. non-existent core records are inserted from the update table.

It is not necessary that records missing from the update table
cause deletes in the core table.

Try this (assuming fieldU exists in both tables and fieldC is only in core table, and the rows are matched up by the field named "id"):

insert or replace into coreTable(fieldU, fieldC)
select u.id, u.fieldU, c.fieldC
from updateTable u left join coreTable c on (u.id = c.id);

This requires that coreTable have a uniqueness constraint on id field, e.g. having it as a primary key.

Igor Tandetnik

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to