本文介紹了如何將字符串附加到 MySQL 中的現有字段?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我想將我所有記錄上的代碼更新為當前的代碼,以及 _standard 有什么想法嗎?
I want to update the code on all my record to what they currently are plus _standard any ideas?
例如,如果代碼是 apple_1 和 apple_2,我需要它們是 apple_1_standard 和 apple_2_standard
So for example if the codes are apple_1 and apple_2 I need them to be apple_1_standard and apple_2_standard
id code
------------
1 apple_1
1 apple_2
偽查詢:
update categories set code = code + "_standard" where id = 1;
預期結果:
id code
----------------------
1 apple_1_standard
1 apple_2_standard
推薦答案
您需要使用 CONCAT()
MySQL 中用于字符串連接的函數:
You need to use the CONCAT()
function in MySQL for string concatenation:
UPDATE categories SET code = CONCAT(code, '_standard') WHERE id = 1;
這篇關于如何將字符串附加到 MySQL 中的現有字段?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!