我使用以下代码来更新订单状态,但它给出了错误,我错了
UPDATE wp_posts set post_status = 'wc-completed'
FROM wp_posts
LEFT JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id
LEFT JOIN wp_woocommerce_order_itemmeta ON wp_postmeta.post_id = wp_woocommerce_order_itemmeta.order_item_id
LEFT JOIN wp_woocommerce_order_items ON wp_posts.ID = wp_woocommerce_order_items.order_item_id
WHERE wp_posts.post_type = "shop_order"
AND wp_woocommerce_order_items.order_item_id = 68792
您的查询有一些错误,请尝试以下操作:
UPDATE wp_posts p
INNER JOIN wp_wc_orders o ON p.ID = o.id
INNER JOIN wp_woocommerce_order_items oi ON p.ID = oi.order_id
INNER JOIN wp_woocommerce_order_itemmeta oim ON oi.order_item_id = oim.order_item_id
SET p.post_status = 'wc-completed', o.status = 'wc-completed'
WHERE p.post_type = 'shop_order'
AND oi.order_item_id = 68792;
应该可以。