Search code examples
phpmysqlmathematical-expressions

MYSQL Mathematical Operations Priority


this my code:

$stmt->prepare("UPDATE ".$PapierTableName."  SET nrating=nrating+1,`rating`=(rating+?)/nrating  WHERE `id`=? AND `title`=?");
$stmt->bind_param('iis', $rat,$id,$tit);

My question is about the priority: in this operation

`rating`=(rating+?)/nrating

the nrating that will be used is the one already incremented or the one that is present in column?
Thanks


Solution

  • That already incremented one; due to Operator Precedence

    Parentheses may be used to force precedence, if necessary