/articles(ID,Qte_stock,PU)/
/DETAILS_BON_ACHAT(ID,qte,prix,id_article)/
I want to update PU (price of product) in articles A table (items of stor) for each record in DETAILS_BON_ACHAT D table (
NOTE : the new PU must be calculated like this ( ((D.prixD.qte)+(A.PUA.Qte_stock))/(D.qte+A.Qte_stock))
I TRIED enter image description here
/*articles(ID,Qte_stock,PU)*/
/*DETAILS_BON_ACHAT(ID,qte,prix,id_article)*/
USE bitsclic_easy_erp;
UPDATE articles set PU=(
SELECT ((D.prix*D.qte)+(A.PU*A.Qte_stock))/(D.qte+A.Qte_stock)
FROM DETAILS_BON_ACHAT D
INNER JOIN articles A
ON D.id_article = A.ID
WHERE D.id_bon='1'
GROUP BY D.id_article
);
i got error :Error Code: 1093. You can’t specify target table ‘articles’ for update in FROM clause
hamza meliki is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
4