I have a strong feeling that all mathematical operations unnecessary to the query itself must be pre-formed outside the query. For instance:
$result = mysql_query(SELECT a, a*b/c as score FROM table)
while ($row = mysql_fetch_assoc($result))
{
echo $row['a'].' score: '.$row['score'].<br>;
}
against
$result = mysql_query(SELECT a, b, c FROM table)
while ($row = mysql_fetch_assoc($result))
{
echo $row['a'].' score: '.$row['a']*$row['b']/$row['c'].<br>;
}
the second option is usually better, especially with complex table joins and the like. This is my suspicion, I lack confirmation.,.
source
share