in reply to Superior way to update SQL tables
and the other would be likeUPDATE real_table R SET (col1, col2, col3,...) = SELECT col1, col2, col3,... FROM scratch S WHERE R.key_val1 = S.key_val1 AND R.key_val2 = S.key_val2 AND ... ;
The snag with that sounds like some of the inserts might fail (since you mention skipping). At least you should be able to do the UPDATE, and delete those records. Then you can loop through what's left for INSERT/SKIP.INSERT INTO real_table R SELECT * FROM scratch S WHERE NOT EXISTS ( SELECT 1 FROM real_table WHERE key_val1 = S.key_val1 AND key_val2 = S.key_val2 AND ... )
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Superior way to update SQL tables
by radiantmatrix (Parson) on Sep 08, 2004 at 15:21 UTC | |
by Roy Johnson (Monsignor) on Sep 08, 2004 at 16:16 UTC |