I have a tables that looks like the following:
Table - order
id purchase_order_item_id amount
1 1324 0.0
2 2435 50.2
3 5643 87.2
4 6475 0.0
Table - purchase_order_item
id item_id
1324 82
2435 83
5643 84
6475 85
Table - item
id amount
82 76.1
83 50.2
84 87.2
85 65.9
Now I want to check if Order table is having value 0.0 for amount. In this case I have to get amount data from table item (Order->purchase_order_item->item) and update in order table.
I have written below update query which is not running.Trying to correct it.
UPDATE order
INNER JOIN purchase_order_item ON purchase_order_item.id = order.purchase_order_item_id
SET
order.amount=
(
SELECT item.amount from item
INNER JOIN purchase_order_item ON purchase_order_item.item_id=item.id
)
where order.amount=0.0;
I am new in mysql query and trying to write correct update query.