Update query (access & vb.net)
Posted
by yae
on Stack Overflow
See other posts from Stack Overflow
or by yae
Published on 2010-05-19T11:05:36Z
Indexed on
2010/05/19
11:10 UTC
Read the original article
Hit count: 132
Hi:
I have to update some fields of a table of access according to the value of parameter. If this paramter is "true" I need to update.
Table
idInvoice
price
percentageTax1
tax1
percentageTax2
tax2
total
Example values:
idinvoice: 12300
price: 100 €
percentageTax1: 10 %
tax1= 10€
percentageTax2: 5 %
tax2: 5€
total: 115 € (result: 100€+10€+5€)
Ok. If the parameter on that I have commented before is "true" I must update the percentages and then update the total. I need to replace the "old" percentages by new percent.
Ok I can do it 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 any an alternative to do this in 1 query?
© Stack Overflow or respective owner