2014-09-03 46 views
0

我需要更新我的mysql數據庫中的一行,但我不想替換已存儲在其中的數據。例如:查詢mysql更新無需替換現有數據

select books from storedb where id='Rick'; 

結果:書籍=「例1」

,但我需要更新該行並添加更多的書。

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

但它取代了當前的數據,所以我需要這樣做,而不會取代當前的數據。 somethink這樣的:書籍='例1 - 示例2" ;

回答

-1

所以你需要一個字符串連接 試試這個:

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

非常感謝,它的工作! – OverHead 2014-09-04 00:00:00

+0

沒問題,請你?接受這個答案呢?謝謝 – Florian 2014-09-04 00:03:56