I have a column name ‘balance’ & ‘status’. I got the Qty from users input.
What I want to perform is update balance (balance-qty)
and after updating balance if balance is 0 then I want to change status to 2.
Is it possible to perform these 2 operations in one query?
Thanks in advance.
Yes, you can do that it one query, all need need to do is to use
InLine IFstatement.and since you have mentioned that the
Qtycame from the user, please take a look at the article below to learn how to prevent fromSQL Injection. By using PreparedStatements you can get rid of using single quotes around values.