Skip to content Skip to sidebar Skip to footer

Mysql Update With A Subquery In Safe Update Mode

I have the following database: The following query calculates the total amount, that comes from multiplying the products prices and the respective quantity bought, from the order

Solution 1:

You should be able to do that by changing this one line in your subquery this will set the subquery WHERE clause to match your records in the outer table.

WHERE i.id_pedido =1

TO

WHERE i.id_pedido = p.id_pedido

Then you can remove the outer WHERE, unless you really want to just restrict it to p.id_pedido=1

Post a Comment for "Mysql Update With A Subquery In Safe Update Mode"