OverHead
OverHead

Reputation: 13

mysql update without replacing existing data

I need to update a row in my mysql database, but i don't want to replace the data that is already stored in it. example:

select books from storedb where id='Rick';

result of the query: Books = "example1"

but i need to update that row and add more books.

update storedb set books='example2' where id='Rick';

but it replaces the current data, so i need to do it without replacing current data. somethink like this: books='example1 -- example2";

Upvotes: 0

Views: 823

Answers (1)

Florian
Florian

Reputation: 175

so you need a string concatenation? Try this:

update storedb set books=CONCAT(books,' -- ', 'example2') where id='Rick';

Upvotes: 1

Related Questions