码迷,mamicode.com
首页 > 数据库 > 详细

mysql concat update中拼接字符串

时间:2017-12-26 12:02:58      阅读:259      评论:0      收藏:0      [点我收藏+]

标签:warning   body   cte   png   拼接字符串   --   csharp   date   concat   

mysql> select id,avatar from tf_user;
+----+--------------+
| id | avatar       |
+----+--------------+
|  1 | avatar_1.png |
|  2 | avatar_6.png |
|  3 | avatar_1.png |
|  4 | avatar_5.png |
|  5 | avatar_5.png |
|  6 | avatar_4.png |
|  7 | avatar_6.png |
|  8 | avatar_3.png |
|  9 | avatar_4.png |
| 10 | avatar_1.png |
| 11 | avatar_5.png |
| 12 | avatar_1.png |
+----+--------------+
12 rows in set (0.01 sec)

mysql> update tf_user set avatar = concat("chongwu_",avatar);    //这里用“+”是数学逻辑运算符号;用php中的".",链接字符串也是不行的;
Query OK, 12 rows affected (0.01 sec)
Rows matched: 12  Changed: 12  Warnings: 0

mysql> select id,avatar from tf_user;
+----+----------------------+
| id | avatar               |
+----+----------------------+
|  1 | chongwu_avatar_1.png |
|  2 | chongwu_avatar_6.png |
|  3 | chongwu_avatar_1.png |
|  4 | chongwu_avatar_5.png |
|  5 | chongwu_avatar_5.png |
|  6 | chongwu_avatar_4.png |
|  7 | chongwu_avatar_6.png |
|  8 | chongwu_avatar_3.png |
|  9 | chongwu_avatar_4.png |
| 10 | chongwu_avatar_1.png |
| 11 | chongwu_avatar_5.png |
| 12 | chongwu_avatar_1.png |
+----+----------------------+
12 rows in set (0.00 sec)

  

mysql concat update中拼接字符串

标签:warning   body   cte   png   拼接字符串   --   csharp   date   concat   

原文地址:https://www.cnblogs.com/pansidong/p/8116711.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!