mysql> select concat(substring('abcdefg',1,5),'欢迎光临',substring('abcdefg',6,2 )); +----------------------------------------------------------------------+ | concat(substring('abcdefg',1,5),'欢迎光临',substring('abcdefg',6,2)) | +----------------------------------------------------------------------+ | abcde欢迎光临fg | +----------------------------------------------------------------------+ 1 row in set (0.00 sec)这个是利用mysql的函数得出来的,但是直接插入数据库时却出错,如果是用程序来做话可能要将上面的结果集对一个字符串变量赋值后,再用其变量插入数据库应该就没有问题了. mysql> update a set name=(select concat -> (substring('abcdefg',1,5),'欢迎光临',substring('abcdefg',6,2)) -> ) where id=1; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(subs tring('abcdefg',1,5),'欢迎光临',substring('abcdefg',6,2)) ) where id=1' at line 2
believefym(暮色,miss,迷失,miss) 你究竟有没有看懂呀,我测试过lw1a2(一刀 [email protected])的方法是不行的。 update tablename set columnname=columnname+'欢迎光临CSDN_专家门诊' columnname=0了!
我想这不是我需要的
我需要的是——插入内容!
好比:原来的纪录是“abcdefg”,插入后,变成“abcde欢迎光临CSDN_专家门诊fg”这样。
如果把文件插入到原有内容中呢(可以是任意地方,但不能是开头或结尾)?
好比:原来的纪录是“abcdefg”,插入后,变成“abcde欢迎光临CSDN_专家门诊fg”这样。
我就是不会呀!我刚学的MYSQL
至于什么位置,就以我举例那个该如何做?好比:原来的纪录是“abcdefg”,插入后,变成“abcde欢迎光临CSDN_专家门诊fg”这样。有一个实际的例子,我也许能解决问题的
拜托了
我想您明白了我的意思
));
+----------------------------------------------------------------------+
| concat(substring('abcdefg',1,5),'欢迎光临',substring('abcdefg',6,2)) |
+----------------------------------------------------------------------+
| abcde欢迎光临fg |
+----------------------------------------------------------------------+
1 row in set (0.00 sec)这个是利用mysql的函数得出来的,但是直接插入数据库时却出错,如果是用程序来做话可能要将上面的结果集对一个字符串变量赋值后,再用其变量插入数据库应该就没有问题了.
mysql> update a set name=(select concat
-> (substring('abcdefg',1,5),'欢迎光临',substring('abcdefg',6,2))
-> ) where id=1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '(subs
tring('abcdefg',1,5),'欢迎光临',substring('abcdefg',6,2))
) where id=1' at line 2
update tablename set columnname=columnname+'欢迎光临CSDN_专家门诊'
columnname=0了!