Reputation: 587
I would like to update a field but previously entered contents should be kept. Is there a way to this with one query without to select first the content.
example I have a field by name protocol what is having entries exmpl.
than on update should look like
instead of this a better workaround
SELECT protocol FROM my_table WHERE id = 1
than I should add the new entry to my field and make the update
UPDATE my_table
SET protocol=new value
WHERE id=1
Upvotes: 1
Views: 124
Reputation: 75704
I suppose you want to concatenate the existing and the new string. The function is called CONCAT in MySQL:
UPDATE MyTable SET protocol = CONCAT(protocol, "\n", "new entry");
Upvotes: 2