V
V
Valery Gutin2018-05-23 10:28:36
MySQL
Valery Gutin, 2018-05-23 10:28:36

How to subtract a number from a value in a MYSQL table?

How to subtract from the value of amount (in the table) the number $sum?
I tried that - didn't work

$sum = 1;

$mysqli->query("UPDATE orders SET redeemed = '$change',  amount -= '$sum' WHERE id = '$id'");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yan-s, 2018-05-23
@alohamneploha

UPDATE orders SET redeemed = '$change',  amount = amount - '$sum' WHERE id = '$id'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question