求一条mysql update语句(急。。。)分不够再加! 字段1 字段2a ba c现在我想将字段2中的值改为如下(所有字段1为a的行,改变字段2为:‘字段1_字段2’)字段1 字段2a a_ba a_c可以通过sql语句直接来实现吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 update tt set 字段2=字段1+'_'+字段2 谢谢wwwwb 我试过了,不行!还有没有其他办法?是不是需要类型转换? update tt set 字段2=CONCAT(字段1,'_',字段2) 你是那个版本的?我这里是mysql 5.0,测试正常。你那里出现什么错误? 我也是5.0,我贴出来吧错误SQL 查询: UPDATE crop SET city = concat( province, '_', city ) WHERE id =45 MySQL 返回: #1146 - Table 'yiwubase.crop' doesn't exist mysql> create table c_t ( -> f1 varchar(255) not null, -> f2 varchar(255) not null) engine myisam;Query OK, 0 rows affected (0.00 sec)mysql> insert into c_t -> values -> ('a','b'),('a','c');Query OK, 2 rows affected (0.01 sec)Records: 2 Duplicates: 0 Warnings: 0mysql> update c_t set f2 = concat(f1,'_',f2);Query OK, 2 rows affected (0.00 sec)Rows matched: 2 Changed: 2 Warnings: 0mysql> select * from c_t;+----+-----+| f1 | f2 |+----+-----+| a | a_b | | a | a_c | +----+-----+2 rows in set (0.00 sec)mysql> MySQL Error:2013 mysql静态编译问题。 将一个列的数据取前几位并更新该列的sql语句 求一sql语句的写法,根据表名获取表的结构,包括字段名,字段类别,字段大小,是否主键,希望大虾给与帮助,在线等 关于数据库备份的问题? 不用子查询,如何实现这个sql语句 求update语句的使用 我想将一个数据库含表的结构和数据全部copy后,重命名,应怎么做? MYSQL order by limit 问题 装WAMP3.0.6出现的mysql错误 如何批量删除字段中的不规则的连接地址 请教sql语句
还有没有其他办法?是不是需要类型转换?
SQL 查询: UPDATE crop SET city = concat( province, '_', city ) WHERE id =45 MySQL 返回: #1146 - Table 'yiwubase.crop' doesn't exist
mysql> create table c_t (
-> f1 varchar(255) not null,
-> f2 varchar(255) not null) engine myisam;
Query OK, 0 rows affected (0.00 sec)mysql> insert into c_t
-> values
-> ('a','b'),('a','c');
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0mysql> update c_t set f2 = concat(f1,'_',f2);
Query OK, 2 rows affected (0.00 sec)
Rows matched: 2 Changed: 2 Warnings: 0mysql> select * from c_t;
+----+-----+
| f1 | f2 |
+----+-----+
| a | a_b |
| a | a_c |
+----+-----+
2 rows in set (0.00 sec)mysql>