Mysql
 sql >> Base de données >  >> RDS >> Mysql

Fonction MySQL Ajouter des prix à partir de plusieurs tables

Essayez ceci,

SET price = 
(
    SELECT  SUM(x.Price) 
    FROM
    (
        SELECT priceFactor AS Price FROM tblCheese WHERE cheeseName = cheese
        UNION ALL 
        SELECT priceFactor AS Price FROM tblMeat WHERE meatName = meat 
        UNION ALL 
        SELECT priceFactor AS Price FROM tblVeggie WHERE veggieName = veg
    ) x
);