我可以将其合并为一个吗?
UPDATE 1_packages k
SET
rrp = (SELECT
SUM(u.quantity * p.rrp) * (sum(p.price_each <> 0 and p.rrp = 0) = 0)
FROM
1_packages_plu u
INNER JOIN
1_products p ON u.fk_products_id = p.id
WHERE
fk_packages_id = k.id)
;
UPDATE 1_packages k
SET
rrp_inc = (SELECT
SUM(u.quantity * p.rrp_inc) * (sum(p.price_each <> 0 and p.rrp_inc = 0) = 0)
FROM
1_packages_plu u
INNER JOIN
1_products p ON u.fk_products_id = p.id
WHERE
fk_packages_id = k.id)
;
答案 0 :(得分:2)
很简单,试试
UPDATE 1_packages k
SET rrp = (SELECT SUM(u.quantity * p.rrp) * (sum(p.price_each <> 0 and p.rrp = 0) = 0)
FROM 1_packages_plu u INNER JOIN 1_products p ON u.fk_products_id = p.id
WHERE fk_packages_id = k.id),
rrp_inc = (SELECT SUM(u.quantity * p.rrp_inc) * (sum(p.price_each <> 0 and p.rrp_inc = 0) = 0)
FROM 1_packages_plu u INNER JOIN 1_products p ON u.fk_products_id = p.id
WHERE fk_packages_id = k.id)
答案 1 :(得分:0)
尝试:
UPDATE table_name
SET column_one = "value one",
column_two = "value two"
WHERE condition