mysql - Is this valid "on duplicate key" syntax? -


i have no place test right , hoping knows don't have wait until tomorrow find out....

   insert item_properties (itemid, propid, value, updateon)  values         (538,  25, 'some description stuff goes here', unix_timestamp()),         (541,  25, 'some description stuff goes here', unix_timestamp()),         (1276, 25, 'some description stuff goes here', unix_timestamp()),         (1319, 25, 'some description stuff goes here', unix_timestamp())      on duplicate key update               itemid   = values(itemid),              propid   = values(propid),              value    = values(value),               updateon = values(updateon)    

can re-written be:

   insert item_properties (itemid, value)  values         (538,  'some description stuff goes here'),       (541,  'some description stuff goes here'),        (1276, 'some description stuff goes here'),       (1319, 'some description stuff goes here')     on duplicate key update               itemid   = values(itemid),              value    = values(value),               propid   = 25,              updateon = unix_timestamp()   

yes?

or no, because propid , updateon can't accessed on dup part without being in values list...?

i tried sqlfiddle told me no ddl or dml statements, selects.


so tested filddle...

insert item_properties (itemid, value)  values         (538,  'some description stuff goes here'),       (538,  'some other description stuff goes here'),       (1276, 'some description stuff goes here'),       (1319, 'some description stuff goes here')     on duplicate key update               itemid   = values(itemid),              propid   = 26,              value    = values(value),               updateon = unix_timestamp() 

turns into:

itemid       propid     value                                    updateon 538          26         other description stuff goes here   1376952345 1276         (null)     description stuff goes here         (null) 1319         (null)     description stuff goes here         (null) 

which isn't intended output...

so... guess 2 things don't same thing , need not re-write code in way suggested. it valid syntax, not correct results.

just clarify (but i'm sure tell initial on duplicate key statement), output should end with...

itemid       propid     value                                    updateon 538          26         other description stuff goes here   1376952345 1276         26         description stuff goes here         1376952345 1319         26         description stuff goes here         1376952345 

thanks help!

it valid sql. above 2 insert ... on duplicate key update statements have identical effects.

this can shown via sqlfiddle, it's inserts have part of ddl.

http://sqlfiddle.com/#!2/56579/1/0

the itemid = values(itemid) pointless if duplicate key.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -