mysql 一张表update另一张表

有三种方法: 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
有三种方法:
 
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);
本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

liunx mysql root账户提示:Your password has expired. To log in you must change it using a client that supports expired passwords,要怎么操作呢? 1、修改 /etc/my.cnf,在 [mysqld] 小节下添加一行:skip-grant-tables=1 这一行配置让 mysqld 启动
MySQL是一种流行的关系型数据库系统,它提供了多种时间类型和模式,用于存储和处理时间数据。本文将详细介绍MySQL时间类型和模式的详细攻略。
首先在官网下载CentOS7镜像,并在VMware虚拟机中新建一台CentOS7虚拟机,将镜像挂载到虚拟机中并启动。
MySQL中出现lock wait timeout exceeded问题的原因是由于两个或多个事物同时请求相同的资源造成的,并且在某一时刻至少一个事务无法获取资源,超过了MySQL默认的等待时间,从而导致事务失败。这种问题的出现会极大地影响数据库的性能和并发能力。
针对“Linux下安装配置MySQL”的问题,我为您提供以下完整攻略:
我们来讲解一下MySQL sql_mode的使用。