你能指导我为什么以下查询不起作用吗?
感谢
UPDATE campaigns SET available='0' WHERE product_id IN (SELECT product_id, sum(stock_qty) AS qty FROM `sku_colors_sizes` GROUP BY product_id HAVING sum(stock_qty) < 1)
答案 0 :(得分:0)
您必须从子查询中仅选择一列以使用IN
谓词对其进行比较,您可以对其进行修改,以便仅选择product_id
,如下所示:
UPDATE campaigns
SET available='0'
WHERE product_id IN (SELECT product_id -- <=====
FROM
(
SELECT product_id, sum(stock_qty) AS qty
FROM sku_colors_sizes
GROUP BY product_id
HAVING sum(stock_qty) < 1
) AS t)