QUESTION 1
I need to update some fields of the access table according to the parameter value. If this parameter is true, I need to update.
Table
idInvoice
Price
percentageTax1
tax1
percentageTax2
tax2
General
Example values:
idinvoice: 12300
price: 100 €
percentTax1: 10%
tax1 = 10 €
percentTax2: 5%
tax2: 5 €
total: 115 € (result: 100 € + 10 € + 5 €)
Ok If the parameter I commented on earlier is "true", I have to update the percentages and then update the total. I need to replace the "old" interest with a new percentage.
Ok, I can do this in 3 queries:
update invocies set percentageTax1=20,tax1=price *(percentageTax1/100) where idInvoice=@number and percentageTax1=10
update invocies set percentageTax2=7,tax2=price *(percentageTax2/100) where idInvoice=@number and percentageTax2=5
update invocies set total=price+tax1+tax2 where idInvoice=@number
. But my question is:
Is there an alternative for this in 1 request?
QUESTION 2
Another update question.
If I have 2 related tables
EXAMPLE TABLE ACCOUNT
idInvoice
General
idInovice
"total" - "" ""
"" "" ?
TOTAL
2:
, . .
1 INNER JOIN table2 ON table1.id = table2.id set table1.field1 = table2.fieldX