mysql更新查询有2个子查询

时间:2016-04-06 08:45:36

标签: mysql

任何人都可以看到以下查询有什么问题吗? 我拥有的值是products_model号000011195001

我需要的是表products_attribute

中所有相应products_id的sum attributes_stock

表products_attribute中products_id 1726的所有attributes_stock的总和为500 这些500需要我在Field products_quantity中的Table产品

当我跑步时,我得到:

UPDATE products As C INNER JOIN (
SELECT SUM( attributes_stock ) AS products_quantiry
FROM products_attributes
WHERE products_id IN(
    SELECT products.products_id
    FROM products
    WHERE products_model LIKE '000011195001'
    )
) 
AS A ON products.products_id = products_attributes.products_id
SET C.products_quantity = A.products_quantiry

表产品 products_model,products_id,products_quantity

000011195001,1726

表products_attribute products_id,attributes_stock

1726年,300

1726,150

1726年,50岁

提前致谢

1 个答案:

答案 0 :(得分:0)

这里(我做了一个sql小提琴,但网站现在还没有工作:'():

<key>NSLocationWhenInUseUsageDescription</key>
<string>[App Name] would like to access your location when running and displayed.</string>