Home >Database >Mysql Tutorial >关联子查询Update语句更新数据

关联子查询Update语句更新数据

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 14:56:551936browse

关联子查询 Update 语句更新数据 无 --方法1:Update?Table1?set?c?=?(select?c?from?Table2?where?a?=?Table1.a)?where?c?is?null?--方法2:update??Aset??newqiantity=B.qiantityfrom??A,Bwhere??A.bnum=B.bnum?--方法3:update????(select?A.bnum?,A.newq

关联子查询Update语句更新数据

--方法1:
Update?Table1?set?c?=?(select?c?from?Table2?where?a?=?Table1.a)?where?c?is?null?

--方法2:
update??A
set??newqiantity=B.qiantity
from??A,B
where??A.bnum=B.bnum?

--方法3:
update
????(select?A.bnum?,A.newqiantity,B.qiantity?from?A?left?join?B?on?A.bnum=B.bnum)?AS?C
set?C.newqiantity?=?C.qiantity
where?C.bnum?=XX?
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn