0

我可以把它合二为一吗?

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)
;
4

2 回答 2

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)
于 2013-07-09T15:50:55.193 回答
0

尝试 :

UPDATE table_name 
SET column_one = "value one", 
    column_two = "value two"
WHERE condition
于 2013-07-09T15:50:37.353 回答