欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

mysql 多表update

程序员文章站 2022-05-24 21:08:45
...
-- 方式1
update uc_organization,uc_users 
set uc_organization.org_name=uc_users.nick_name 
where uc_organization.uid=uc_users.uid and (uc_organization.org_name is null  or uc_organization.org_name='')

-- 方式2
update uc_organization inner join uc_users 
on uc_organization.uid = uc_users.uid 
set uc_organization.org_name=uc_users.nick_name 
where uc_organization.org_name is null  or uc_organization.org_name=''

 


UPDATE aq_users_expan,aq_answer
SET aq_users_expan.`answer_count`=(SELECT COUNT(*) FROM aq_answer WHERE aq_answer.uid=aq_users_expan.`uid`)

相关标签: mysql update