MySQL Forums
Forum List  »  Stored Procedures

updation order of fields in a table
Posted by: rook deis
Date: June 20, 2012 10:26PM

Hi,

i have a table like below

tbl1
AmtDR = 1000
AmtCR = 2000

i want either one of the field to have value. either AmtDr or AmtCr. now i have value in both fields. so i want to update it with the below query

Update tbl1 set AmtDr=if(AmtDr-AmtCr>=0,AmtDr-AmtCr,0),
AmtCr=if(AmtDr-AmtCr>=0,0,abs(AmtDr-AmtCr))

result AmtDR=0 AmtCR=2000
expected was AmtDr=0 AmtCr=1000

the logic for the result is correct only. but is it possible to do this in a single query to get the expected result

Thanks

Options: ReplyQuote


Subject
Views
Written By
Posted
updation order of fields in a table
1390
June 20, 2012 10:26PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.