请问一条update的sql语句如何更新两张表相关联的内容呢? 就像用inner join这种连接写法可以一条sql更新两张表相关联的字段吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 mysql> create table ta(id int primary key,col int);Query OK, 0 rows affected (0.11 sec)mysql> create table tb(id int primary key,col int);Query OK, 0 rows affected (0.06 sec)mysql>mysql> insert into ta values (1,111);Query OK, 1 row affected (0.06 sec)mysql> insert into tb values (1,222);Query OK, 1 row affected (0.08 sec)mysql>mysql> update ta inner join tb on ta.id=tb.id -> set ta.col=100,tb.col=200;Query OK, 2 rows affected (0.06 sec)Rows matched: 2 Changed: 2 Warnings: 0mysql> select * from ta;+----+------+| id | col |+----+------+| 1 | 100 |+----+------+1 row in set (0.00 sec)mysql> select * from tb;+----+------+| id | col |+----+------+| 1 | 200 |+----+------+1 row in set (0.02 sec)mysql> 谁能教我 MySQL GUI Tools 怎么用 mysql root 用户不能授权 MYsql视图创建问题 数据库的查询(给定一个表数据,生成新表中数据),望大侠们指导 请来看看我的SQL语句哪里出了问题! 关于在linux下安装mysql的问题 gbk编码问题. 现在求一SQL语句,急切中…… 关于新版本的mysql的连接问题 如何用mysql提供的C API实现文件的存取? 求一复合distinct语句 请教个mysql的查询语句?
Query OK, 0 rows affected (0.11 sec)mysql> create table tb(id int primary key,col int);
Query OK, 0 rows affected (0.06 sec)mysql>
mysql> insert into ta values (1,111);
Query OK, 1 row affected (0.06 sec)mysql> insert into tb values (1,222);
Query OK, 1 row affected (0.08 sec)mysql>
mysql> update ta inner join tb on ta.id=tb.id
-> set ta.col=100,tb.col=200;
Query OK, 2 rows affected (0.06 sec)
Rows matched: 2 Changed: 2 Warnings: 0mysql> select * from ta;
+----+------+
| id | col |
+----+------+
| 1 | 100 |
+----+------+
1 row in set (0.00 sec)mysql> select * from tb;
+----+------+
| id | col |
+----+------+
| 1 | 200 |
+----+------+
1 row in set (0.02 sec)mysql>