首页 > 数据库技术 > 详细

mysql用一个表更新另一个表

时间:2015-01-18 18:27:03      阅读:365      评论:0      收藏:0      [点我收藏+]

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用一个表更新另一个表

原文:http://www.cnblogs.com/emanlee/p/4231976.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!