MySQL从其他表取字段数据更新到本表
2019-02-16 09:13:36
MySQL
MySQL从别的表取字段数据更新到本表
eg.从table2中取slug字段更新到table1中的slug字段(按照name相同)
- SQL1
update table1 T1 join table2 T2 on T1.name = T2.name set T1.slug = T2.slug;
- SQL2
update table1 T1 set T1.slug = (select T2.slug from table2 T2 where T1.name = T2.name);
- SQL3
update table1 T1 set T1.slug = T2.slug from T1 join table2 T2 on T1.name = T2.name;
viencoding.com版权所有,允许转载,但转载请注明出处和原文链接: https://viencoding.com/article/62
欢迎小伙伴们在下方评论区留言 ~ O(∩_∩)O
文章对我有帮助, 点此请博主吃包辣条 ~ O(∩_∩)O
评论
There are no comments yet.