mysql中使用concat例子
生活随笔
收集整理的這篇文章主要介紹了
mysql中使用concat例子
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
數據庫為mysql,需要把舊門店記錄的note字段的資料追加到新門店的note資料的后面
舊記錄id為old_terminal_id,新記錄id為new_terminal_id,提供格式如下:
共有2000多需要轉換。
存在多條舊門店合并到同一個新門店的情況,最終新門店的note字段需要自己note原資料加上全部舊門店的note資料。
在excel中拼接SQL:
select @note1:=max(note) from cmdm_terminal a where a.terminal_id=149356;update cmdm_terminal set note=concat(note,@note1) where terminal_id=147611; select @note2:=max(note) from cmdm_terminal a where a.terminal_id=280149;update cmdm_terminal set note=concat(note,@note2) where terminal_id=147663; select @note3:=max(note) from cmdm_terminal a where a.terminal_id=291854;update cmdm_terminal set note=concat(note,@note3) where terminal_id=147692;......?excel中是這樣寫的:
=CONCATENATE("select @note",A2,":=max(note) from cmdm_terminal a where a.terminal_id=",B2,";update cmdm_terminal set note=concat(note,@note",A2,") where terminal_id=",D2,";")?
轉載于:https://www.cnblogs.com/powerwu/p/5163090.html
總結
以上是生活随笔為你收集整理的mysql中使用concat例子的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: LintCode 字符串查找
- 下一篇: SQL拼接字段数据