I have a query (Code
is the PRIMARY KEY
):
INSERT INTO table (Code, ... events)
VALUES
(1, ... CONCAT(events, 'BAR')),
(2, ... CONCAT(events, 'BAR')),
...
ON DUPLICATE KEY
UPDATE ... events = VALUES(events)
My intention is that the events
value being inserted is concatenated to the existing value if there's already a row for the given key.
With my query, assuming the existing value of events
is FOO
, the new events
values are always 'BAR'
instead of 'FOOBAR'
.
What is the correct way to achieve what I want?