I have a row called totalkills and one called totaldeaths, how could i have it return the ratio of them both EG totalkills = 100 totaldeaths = 10 ratio = 10/1
That is the query you use, and it will return the ratio you are looking for.
Dan
__________________
If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.
Step 1: Learn. Step 2: Search. Step 3: Post here.
If you're aiming to get fractions from the table you can use this:
Code:
DELIMITER ~~
CREATE FUNCTION normalized_fraction(a int, b int) RETURNS text
LANGUAGE SQL
DETERMINISTIC
NO SQL
BEGIN
DECLARE tmp, orig_a, orig_b int;
IF b = 0 THEN
RETURN NULL;
END IF;
SET orig_a = a;
SET orig_b = b;
REPEAT
SET tmp = b;
SET b = a % b;
SET a = tmp;
UNTIL b = 0
END REPEAT;
SET orig_a = orig_a / a;
SET orig_b = orig_b / a;
RETURN CONCAT(orig_a, '/', orig_b);
END~~