mysql中使用concat例子
2016-01-27 14:16
519 查看
数据库为mysql,需要把旧门店记录的note字段的资料追加到新门店的note资料的后面
旧记录id为old_terminal_id,新记录id为new_terminal_id,提供格式如下:
共有2000多需要转换。
存在多条旧门店合并到同一个新门店的情况,最终新门店的note字段需要自己note原资料加上全部旧门店的note资料。
在excel中拼接SQL:
excel中是这样写的:
旧记录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,";")
相关文章推荐
- mysql like ‘%...%’ 慎用啊
- 允许本地mysql数据库本远程连接访问
- mysql 各种实际常用疑难sql整理
- MySQL高效分页解决方案集
- mysql 数据库随笔
- mysql执行show processlist unauthenticated user 解决方法
- 如何利用一个数据库中间件扩展MySQL集群——kingshard使用指南
- xampp修改MySQL密码
- MySql log_bin
- mysql-group_concat
- MySQL性能优化的最佳20+条经验
- mysql从命令行执行sql语句
- Mysql 行转列
- MySQL查询测试经验
- (转)如何将数据库从SQL Server迁移到MySQL
- mysql主从复制显示正常,数据没同步现象。
- MySql自动插入当前时间
- is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
- mysql-group_concat
- MySQL的lock tables和unlock tables的用法(转载)