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

liuqiang 2021年03月26日 71次浏览
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