Reputation: 95
MySQL will not update a null or empty field, but seems ok if I add something to the field before hand.
UPDATE trip set MYZID=concat(MYZID, '1,') WHERE id=93
Upvotes: 2
Views: 120
Reputation: 164089
The function concat()
as stated in the documentation:
returns NULL if any argument is NULL
so to make it work use coalesce()
:
UPDATE trip set MYZID=concat(coalesce(MYZID, ''), '1,') WHERE id=93
Upvotes: 3
Reputation: 12953
You should use ifnull function and set it to empty string in case of null
UPDATE trip set MYZID=concat(ifnull(MYZID, ''), '1,') WHERE id=93
Upvotes: 1
Reputation: 393
From https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_concat
CONCAT() returns NULL if any argument is NULL.
Upvotes: 2