Created
January 19, 2018 10:14
-
-
Save Hotfirenet/041b29ff3f32db6ca009be8ea900f4ab to your computer and use it in GitHub Desktop.
Mysql UPDATE, SELECT With SUM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE ps_affiliate A | |
INNER JOIN | |
( | |
SELECT id_order, SUM(product_quantity) AS nb_article_order | |
FROM ps_order_detail | |
GROUP BY id_order | |
) B | |
ON B.id_order = A.id_order | |
SET A.nb_article_order = B.nb_article_order |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
UPDATE ps_affiliate A
INNER JOIN
(
SELECT id_affiliate, MAX(date_add) AS date_lastUpd
FROM ps_affiliate_history
GROUP BY id_affiliate
) B
ON B.id_affiliate = A.id_affiliate
SET A.date_lastUpd = B.date_lastUpd