0

I've got the following syntax to update a field called "line1" in a mysql table called "addresses" However, instead of just replacing it, I would like to keep the original value in line1 but add my new value at the end of it with a space.

UPDATE addresses SET line1="Road" WHERE id=34

Any ideas how this could be done?

Thanks

John
  • 6,417
  • 9
  • 27
  • 32
  • almost duplicate of http://stackoverflow.com/questions/680801/how-to-prepend-a-string-to-a-column-value-in-mysql - it is about prepending – qdinar Apr 09 '17 at 15:41

1 Answers1

0

Use CONCAT and refer to the current value by the name of the column :

UPDATE addresses SET line1=CONCAT(line1,' Road') WHERE id=34

or

UPDATE addresses SET line1=CONCAT(line1,' ', 'Road') WHERE id=34
Denys Séguret
  • 372,613
  • 87
  • 782
  • 758