MySQL Forums
Forum List  »  General

Re: any way to "ignore" a value in an INSERT/UPDATE query?
Posted by: Rick James
Date: July 12, 2013 09:22AM

I would load the new data in a temp table, then do three batch operations:

Copy in 'new' rows:
INSERT INTO TABLE ... SELECT ... FROM tmp LEFT JOIN tbl ON ... WHERE .. IS NULL;
Update those that have both a and b:
UPDATE tbl JOIN tmp ON ... SET tbl.b = tmp.b, tbl.a = tmp.a WHERE tmp.a IS NOT NULL
Update those that have just b:
UPDATE tbl JOIN tmp ON ... SET tbl.b = tmp.b WHERE tmp.a IS NULL;

(If your PKey is AUTO_INCREMENT, have you noticed that some values are being 'burned' by IODKU?)

Options: ReplyQuote


Subject
Written By
Posted
Re: any way to "ignore" a value in an INSERT/UPDATE query?
July 12, 2013 09:22AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.