mysql语句个人收藏 用一个表中的字段更新另一个表的数据

1,修改1列

update student s, city cset s.city_name = c.namewhere s.city_code = c.code;

2,修改多个列

update  a,  bset a.title=b.title, a.name=b.namewhere a.id=b.id

3,采用子查询

update student s set city_name = (select name from city where code = s.city_code);

本文转载自:https://blog.csdn.net/shiyong1949/article/details/78471727

王加文博客
请先登录后发表评论
  • latest comments
  • 总共0条评论