网站制作学习网PHP→正文:mysql 两个表更新,多表更新
字体:

mysql 两个表更新,多表更新

PHP 2015/3/23 22:01:21  点击:不统计

原载于:转www.载for网站制作学习asp必.cn究
 在常见的mysql操作中有这样的一种需求,根据一个表内容更新另一个表的内容,比如

用户表forasp_user
id  username pwd
1   jack xxxx
2   rose    xxxx
..
 
成绩表cn_score
uid  score
1    99
2    98
..
需求 在score中新增 username 将uid 和用户表user id对应并更新到score中
得到 成绩表cn_score
uid  score username
1    99    jack
2    98   rose
..
 
mysql多表更新很简单,实现上述功能
update forasp_user,cn_score set cn_score.username = forasp_user.username where forasp_user.id = cn_score.uid
这样便实现了多表更新

原载于:网f站o学a习s制p作.cn

·上一篇:Thinkphp用Redis存储session >>    ·下一篇:session 二级域名并存,二级域名session共享 >>
推荐文章
最新文章