here is the query
$query = "SELECT count(stat_id)
FROM user_stat
WHERE stat_exp > (
SELECT stat_exp
FROM user_stat
WHERE stat_id=$id
)";
as you can see, this query return only 1 result.
the result is where a stat_id will be located when ordered by stat_exp.
thx to nnichols... or I never know about subquery
But, here is one problem
what if, there are a LOT of them. lots and lots of ids?
to do the query for each one of the id? repeatingly? wow.. that's going to query about 100 times per page and that's very inefficient....
and what if. I want more?
if there is more than stat_exp, there are stat_win, stat_lose, stat_draw and such?
how could that be possible?