我一直在寻找,但我仍然不明白为什么它是错误的。我检查了子查询,它们只返回 1 行。
UPDATE ps_order_history
SET id_order_state = 18
WHERE id_order =
(
SELECT max(p.id_order)
FROM ps_orders p
INNER JOIN ps_order_detail d ON d.id_order = p.id_order
INNER JOIN ps_order_history oh ON oh.id_order = p.id_order
WHERE d.product_name = "Academia Mastermaq"
AND p.id_customer =
(
SELECT id_customer
FROM ps_customer
WHERE firstname = "Cristiano"
AND lastname = "Ferreira dos Santos"
LIMIT 1
)
)
Error Code: 1093. You can't specify target table 'ps_order_history'
for update in FROM clause
谢谢!