I am writing a script that calculates a Kill-Death Ratio (KDR) based on values obtained from a MySQL table. I am fixing somebody else's code. I have managed to get most of it working again. However, I have got stuck here. The KDR is calculated by adding all the kills, and dividing by the number of deaths of the player. But, if the player has never died, then the KDR comes out at 0. I need a way to read the 0, as a 1 when evaluating the KDR. I did google this, and tried to write a UDF I could use, but alas it did not help.
Below is the SQL query in question
function get_leaders($civ, $neu, $riv){
$sSQL = "SELECT *, ((civilian_kills * _civ + neutral_kills * _neu + rival_kills * _riv) / deaths ) as KDR
from sc_players
order by KDR DESC
LIMIT 100;";