I am developing a fixed assets management system and I have two tables where there are low acquired assets, one tables is bajasaf
and the other is distribdebajas
. In bajasaf
the information is saved as the id_baja, fecha_baja, cantidad_baja
and in the table distribdebajas
the id_baja, id_adquisicion, cantidad_rebajada y saldo_restante
is saved, the saldo_restante
is calculated for the same acquisition and in distribdebajas
there can be several losses with different balances, until it reaches zero, as shown in the image.
I need to delete a low, for example this:
I also delete the rows with balance lower than the row that was removed in this case from the photo, it would be with the balance 2 and 0 and I would leave only the row with balance 12.
EYE: The elimination I do from the low table and it is in the form of CASCADE
, so I delete the row with the same id_baja
in distribdebajas
, but I also need you to delete the rows as in the example explained.