小编典典

使用SQL从INNER JOIN转换UPDATE以在MySQL中使用

sql

我想在MySQL中为我们转换一下:

UPDATE product 
SET price = 12.95 
FROM product 
    INNER JOIN product_to_category ON product.product_id = product_to_category.product_id 
    INNER JOIN category ON product_to_category.category_id = category.category_id 
        AND category.parent_id = 39

MySQL不喜欢FROM部分,而且我不确定INNER JOINs是否能像编写的那样工作。


阅读 253

收藏
2021-03-23

共1个答案

小编典典

UPDATE product 
SET price = 12.95 
WHERE product_id in
(SELECT product_id 
FROM product_to_category 
INNER JOIN category 
ON product_to_category.category_id = category.category_id 
WHERE category.parent_id = 39)
2021-03-23