On 5/30/06, Jim C. Nasby <[EMAIL PROTECTED]> wrote:
Your best bet is to do this as a single, bulk operation if possible.
That way you can simply do an UPDATE ... WHERE EXISTS followed by an
INSERT ... SELECT ... WHERE NOT EXISTS.
 
 
hmm, I don't quite understand what you are saying and I think my basic misunderstanding is how to use the UPDATE ... WHERE EXISTS to merge data in bulk.  Assuming that I bulk COPYed the data into a temporary table, I'd need to issue an UPDATE for each row in the newly created table, right? 
 
For example, for a slightly different key,count schema:
 
CREATE TABLE kc (key integer, count integer);
 
and wanting to merge the following data by just updating the count for a given key to the equivalent of OLD.count + NEW.count:
 
1,10
2,15
3,45
1,30
 
How would I go about using UPDATE ... WHERE EXISTS to update the "master" kc table from a (temporary) table loaded with the above data?
 
 

Reply via email to