I’m writing a php script which will update my sql filed with some math.
Should I make a query to get the filed value first then update the filed or there is something to update the filed with in the query it self
here is the math
$sum = 5 ;
$filed = $filed +(($filed * 100) / $sum) ;
This how the math goes with in the PHP.
Is there any way to get this math done by the query it self ?
Assuming
filedis the name of a column in your table, you can do the math right inside the MySQL query, without involving PHP:Just be sure to set the appropriate conditions in your
WHEREclause so you don’t update rows you don’t intend to update.