I have four fields a, b, price and sum. I need to automatically fill in the sum, but so that the price multiplied by the smaller of the fields. How to make such a condition? Thank!
2 answers
UPDATE `table` SET `sum` = `price` * LEAST(`a`, `b`); |
To find the lowest value, the min function will help you. Http://php.net/manual/ru/function.min.php
$sum = $price*min($a,$b); |
least()function, for example - Mike