当前位置:   article > 正文

mysql根据一个表更新另一个表

mysql根据一个表更新另一个表

1、简单update

update tablea a set a.id = 0

2、根据一张表更新另一张表  update

update tablea a, tableb b set a.bname=b.name where a.bid=b.id and a.id between 10 and 50
update tablea a inner join tableb b on a.bid=b.id set a.bname=b.name where a.id between 10 and 50
between 是>= and <=,即包含两个边界

eg:

UPDATE mn a,mn_yfp b set a.state ='-10' where a.jxstjrId = b.bh and b.State = '-10' and a.state <>'-1' and a.state <>'-10'
/*mn_yfp主表 mn副表*/

3、update 累加 1

update tablea  set CODE_INDEX = CODE_INDEX + 1
 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/450019
推荐阅读
相关标签
  

闽ICP备14008679号