Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

LIxPacoGg's avatar

mysql

Could someone help me with an operation in mysql I have 2 tables Invoices and Change in the 2 invoice data is inserted but in the "Change" there is an extra field where I want to insert the price difference. In other words, the 2 have a total field and I want to subtract the total of invoice 1 minus the total of "Change" and insert this result in the difference field of the "Change" table. 'UPDATE laravel_livewire.descamrep SET laravel_livewire.descamrep.diferencia = ( SELECT SUM(laravel_livewire.facturas.total-laravel_livewire.descamrep.sub_total) FROM laravel_livewire.descamrep WHERE laravel_livewire.facturas.factura=laravel_livewire.descamrep.des_id );

0 likes
1 reply
Snapey's avatar

please format your code blocks with three backticks ``` on their own line before and after code

Please or to participate in this conversation.