Re: update, insert ... gee.. a puzzle
- Date: Thu, 17 Mar 2016 17:24:52 -0400
- From: "Hal.sz S.ndor" <hsv@xxxxxxxx>
- Subject: Re: update, insert ... gee.. a puzzle
2016/03/17 12:47 ... lejeczek:
.. that you experts I hope can crack like a digestive biscuit...
how does one update, or merge or whatever is right technical term for it
- a my.table from my.another table (both are schematically identical, no
foreign keys, one primary key) but..
does it a way so when there is a duplicate only NULLs in my.table get
updated/replaced with proper values from my.another table?
many thanks, specially for actual syntax hints.
Nothing here is easy....
My best is INSERT ... SELECT ... ON DUPLICATE KEY UPDATE ...;
INSERT INTO my.table SELECT * FROM my."another table" ON DUPLICATE KEY
UPDATE /* every single field "f" not in the key thus: */ f =
IFNULL(my.table.f, my."another table".f);
By the way, there always is only one primary key. Maybe you mean that
there is only one field to it?
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql