Reputation: 375
I have a column transfer_quantity
which has an initial value of 0. When I input some number on my input field
<input type="number" name="qtyBuy">
I want to update my transfer_quantity
to my qtyBuy
value.
Here is my initial code:
UPDATE stock_transfer SET stocks_transferred = $qtyBuy WHERE transfer_product_id = 1 ON DUPLICATE KEY UPDATE stocks_transferred = stocks_transferred + $qtyBuy;
Here's an example:
|stocks_transferred|
| 0 |
When I input 10, this should be the result:
|stocks_transferred|
| 10 |
and if I input 25, it should add with the 10 in the
|stocks_transferred|
| 35 |
How do I do this?
Upvotes: 0
Views: 18
Reputation: 137
UPDATE stock_transfer SET stocks_transferred = stocks_transferred + $qtyBuy WHERE transfer_product_id = 1
Upvotes: 1