I have 3 tables.
- InvoiceOriginal
- Invoice
- InvoiceHistory
the invoice table has a foreign key constraint. Each entry in the table of accounts has a corresponding entry in the Invoiceoriginal.
The invoiceOriginal table stores the original invoice values, and the invoice table stores the values ββthat have been changed by the user. this is done to get differences during filing.
The SQL I use is
DELETE i FROM invoice i INNER JOIN InvoiceHistory aih ON i.ClientId = aih.HistoryClientNumber AND i.invoiceNumber = HistoryInvoiceNumber
however, deletion is not possible due to a foreign key constraint.
The table looks like this:
Invoice InvoiceOriginal InvoiceHistory Id FK_InvoiceId ClientId ClientId ClientId InvoiceNumber InvoiceNumber
I need to delete the invoice entry and InvoiceOriginal as soon as the number for this account number is indicated in InvoiceHistory for the same clientId.
Sjman source share