本文介紹了MySQL UPDATE 將數據附加到列中的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我需要更新表名(col1name)
I need to UPDATE tablename (col1name)
如果已經有數據,我需要附加值'a,b,c'如果它是 NULL,我需要添加值 'a,b,c'
If there is already data, I need to append it with values 'a,b,c' If it is NULL, I need to add the values 'a,b,c'
我知道有一個 CONCAT 參數,但不確定 SQL 語法是什么.
I know there is a CONCAT argument, but not sure what the SQL syntax would be.
update tablename set col1name = concat(ifnull(col1name, 'a,b,c'), 'a,b,c')
以上正確嗎?
推薦答案
試試這個查詢:
update tablename set col1name = concat(ifnull(col1name,""), 'a,b,c');
參考這個 sql fiddle 演示.
這篇關于MySQL UPDATE 將數據附加到列中的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!