I have a table which has the id column and score column, I want to sort the table based on score column and then find the specific user who is loading the page and show him his/her position. for example, tell him "your position is 40th".
Well I know how to sort a query:
SELECT id,score FROM `table` ORDER BY `score` DESC
You don't need an
order by for this. Instead:
select 1 + count(*) from table t where t.score > (select t2.score from table t2 where id = $id);