in reply to Re^2: Superior way to update SQL tables
in thread Superior way to update SQL tables
Then any rows that fail insert are skips, and any rows that fail update are skips, and you don't waste time trying to insert rows that should be updates.$to_insert_stmt = q{ SELECT * FROM scratch S WHERE session_id = ? AND NOT EXISTS ( SELECT 1 FROM real_data WHERE key_val1 = S.key_val1 AND ... ) }; $to_update_stmt = q{ SELECT * FROM scratch S WHERE session_id = ? AND EXISTS ( SELECT 1 FROM real_data WHERE key_val1 = S.key_val1 AND ... ) };
|
|---|