我有一個選擇查詢來獲取這樣的資料:
SELECT cpe.entity_id,
cpe.type_id,
cpe.sku,
cped.value AS "PRICE"
FROM catalog_product_entity AS cpe
LEFT JOIN catalog_product_entity_decimal AS cped
ON cped.entity_id = cpe.entity_id
WHERE cpe.type_id = 'configurable' AND cped.attribute_id = 77
現在我想將所有行的 cped.value 列更新為 null,我嘗試了這樣的更新查詢:
UPDATE
cped
SET
cped.value = NULL
FROM
catalog_product_entity AS cpe
LEFT JOIN catalog_product_entity_decimal AS cped
ON cped.entity_id = cpe.entity_id
WHERE
cpe.type_id = 'configurable'
AND cped.attribute_id = 77
但它在第 5 行的“FROM catalog_product_entity AS cpe LEFT JOIN catalog_product_entit ...”附近出現語法錯誤。
我該如何解決這個問題?
非常感謝!
uj5u.com熱心網友回復:
UPDATE沒有子句,所以需要在子句FROM中加入表UPDATE
UPDATE catalog_product_entity_decimal cped
RIGHT JOIN catalog_product_entity AS cpe ON cped.entity_id = cpe.entity_id
SET
cped.value = NULL
WHERE
cpe.type_id = 'configurable'
AND cped.attribute_id = 77;
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/450594.html
上一篇:3表成1
下一篇:MySQL使用多個值更新多行
