mysql用一个表更新另一个表的方法
来源:懂视网
责编:小采
时间:2020-11-09 20:40:43
mysql用一个表更新另一个表的方法
mysql用一个表更新另一个表的方法:Solution 1: 修改1列 update student s, city c set s.city_name = c.name where s.city_code = c.code; Solution 2: 修改多个列 update a, b set a.title=b.title, a.name=b.name where a.id=b.id
导读mysql用一个表更新另一个表的方法:Solution 1: 修改1列 update student s, city c set s.city_name = c.name where s.city_code = c.code; Solution 2: 修改多个列 update a, b set a.title=b.title, a.name=b.name where a.id=b.id

Solution 1: 修改1列
update student s, city c
set s.city_name = c.name
where s.city_code = c.code;
Solution 2: 修改多个列
update a, b
set a.title=b.title, a.name=b.name
where a.id=b.id
Solution 3: 采用子查询
update student s set city_name = (select name from city where code = s.city_code);
以上这篇mysql用一个表更新另一个表的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
您可能感兴趣的文章:
mysql 批量更新与批量更新多条记录的不同值实现方法MySQL UPDATE更新语句精解MySql中使用INSERT INTO语句更新多条数据的例子mysql 记录不存在时插入 记录存在则更新的实现方法mysql 存在该记录则更新,不存在则插入记录的sqlMySQL使用外键实现级联删除与更新的方法mysql 一次更新(update)多条记录的思路MySQL查询结果复制到新表的方法(更新、插入)基于更新SQL语句理解MySQL锁定详解
mysql用一个表更新另一个表的方法
mysql用一个表更新另一个表的方法:Solution 1: 修改1列 update student s, city c set s.city_name = c.name where s.city_code = c.code; Solution 2: 修改多个列 update a, b set a.title=b.title, a.name=b.name where a.id=b.id