数据库
首页 > 数据库> > mysql 把select结果update更新到表中,从查询结果中更新数据

mysql 把select结果update更新到表中,从查询结果中更新数据

作者:互联网

原文链接:https://blog.csdn.net/qq_36823916/article/details/79403696
UPDATE sale
INNER JOIN (
	SELECT
		sale.FNo,
		sale.FEntryID,
		(finishin.FQty) AS qty
	FROM
		sale,
		finishin
	WHERE
		sale.FNo = finishin.FNo
	AND sale.FEntryID = finishin.FEntryID
	ORDER BY
		sale.FNo
) sale2 ON sale2.FNo = sale.FNo
AND sale2.FEntryID = sale.FEntryID
SET sale.FqtyIn = sale2.qty

逻辑:两张表连接获取finishin的重量插入到sale.

 

标签:到表中,sale2,sale,更新,update,finishin,FEntryID,FNo,qty
来源: https://blog.csdn.net/wang0112233/article/details/99641834