How to update data in a database without deleting old data?

I would like to know how to do this. let's say I have this “first” in my database, and if I want to update and add a “second”, in which I can have this format “first, second”. I used this one UPDATE table SET number="second", but it removes the "first". I use php and mysql, thanks

+3
source share
3 answers

I think you mean:

// if number is "first", it will become "first, second"
UPDATE table SET number = CONCAT(number, ", second")

but I do not think you need. Can you explain what you are trying to do?

+5
source
UPDATE table SET number=concat_ws(",", number, "second")
+1
source

, . -, .

, , , :

  • : , . - , .

  • Sous code control . Save the code in the Source Control section so that you can revert to previous versions as needed.

  • Separation of Prod and Dev . If you play Production, you can do a lot of damage. Make double triple sure that you work in an isolated environment.

0
source

Source: https://habr.com/ru/post/1725549/


All Articles