UPDATE tblstocktake ap SET TotalQuantity =
(
SELECT SUM(t.Unitinstock)
FROM tblstocktake t
JOIN tblstocktake a
ON a.productid = t.productid
WHERE a.productid = ap.productid
GROUP BY a.productid
);
Which is not working.
Finally, found a solution which is working
UPDATE tblstocktake LEFT JOIN
(SELECT productid,
SUM(unitinstock) AS baseVal
FROM tblstocktake
GROUP BY productid)
AS totalSum USING (productid)
SET totalquantity=baseVal;
1 comment:
Great!!! solve my problem
Thanks
Post a Comment