0
  • Table: test
  • Columns: column1 column2 column3

An already existing row has a value in column3. I then want to do an SQL update query to that row and keep the already existing value and simply add another alongside it.

  • Column3 datatype is VARCHAR

Is this possible?

Using MySQL

t1f
  • 3,021
  • 3
  • 31
  • 61
  • 1
    What datatype is column 3 ? if string then concat https://dev.mysql.com/doc/refman/8.0/en/string-functions.html#function_concat – P.Salmon Mar 20 '20 at 08:41
  • @P.Salmon Oh, sorry, forgot to mention that. It's a VARCHAR. It'll have something like, for example, `golden cardboard 114`. I'll then, probably, need to add something alongside it like `green cardboard 78`. End result will be `cardboard 114 green cardboard 78` and so on, depending on how many I add. – t1f Mar 20 '20 at 08:43
  • @P.Salmon Thanks for the link, reading now. – t1f Mar 20 '20 at 08:48
  • 1
    Sounds like a terrible idea. see https://stackoverflow.com/questions/3653462/is-storing-a-delimited-list-in-a-database-column-really-that-bad – P.Salmon Mar 20 '20 at 08:49
  • @P.Salmon Oh. Darn it. I guess I have more reading to do. Thank you for pointing it out – t1f Mar 20 '20 at 08:53

1 Answers1

1
UPDATE test
SET column3 = CONCAT(column3, 'additional value')
-- WHERE ...
Akina
  • 39,301
  • 5
  • 14
  • 25
  • I had no clue on the search term to use for this so I could find and read about it. Thank you for the example! – t1f Mar 20 '20 at 08:49