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

刘白猪
2021-03-26 / 0 评论 / 101 阅读
温馨提示:
本文最后更新于2021-03-26,若内容或图片失效,请留言反馈。
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