Monday 19 August 2013

Is this valid "on duplicate key" syntax?

Is this valid "on duplicate key" syntax?

I have no place to test this right now and I was hoping someone knows so I
don't have to wait until tomorrow to find out....
insert into 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 that be re-written to be:
insert into 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 the PropID and UpdateOn can't be accessed by the on dup
part without being in the values list...?
I tried to SQLFiddle but it told me something about no DDL or DML
statements, only selects.

No comments:

Post a Comment