Here is my query:
UPDATE order_product
SET amount = coalesce(
(
SELECT amount_origin + (SELECT sum(amount_to_change)
FROM order_product_edits
WHERE order_product_id = NEW.order_product_id
)
FROM order_product
WHERE id = NEW.order_product_id
)
, 0)
It works well on my local computer (MySQL 8.3) .. but it throws this error on the server (MySQL 8.2):
Table is specified twice, both as a target for 'UPDATE' and as a separate source for data in mysql
Any idea how can I fix it?