当前位置:Gxlcms > 数据库问题 > mysql concat update中拼接字符串

mysql concat update中拼接字符串

时间:2021-07-01 10:21:17 帮助过:132人阅读

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   

人气教程排行