`
In my DataBase I Have a 2 table Called "future_user_detail" and "user_score_detail"
future_user_detail:
future_user_type_id(pk) name profile_img
1 a a.png
2 b b.png
and in user_score_detail:
user_score_detail_id(PK) future_user_detail_id(fk) mind_score(int) body_score(int) soul_score(int)
1 1 10 5 10
2 2 20 5 15
I want to Add the columns(mind_score,body_score,soul_score) values and display them in descending order as well as i want to show the login users rank from this record
i have make a query and getting result but i want the row position also from that filtered query
i have written query like that:
SELECT future_user_detail.future_user_type_id, future_user_detail.name, future_user_detail.profile_img, (
user_score_detail.mind_score + user_score_detail.body_score + user_score_detail.soul_score
) AS Points
FROM future_user_detail
INNER JOIN user_score_detail ON future_user_detail.future_user_type_id = user_score_detail.future_user_detail_id
GROUP BY user_score_detail.mind_score + user_score_detail.body_score + user_score_detail.soul_score DESC
and its give me result like this
future_user_type_id name profile_img Points
2 b b.png 40
1 a a.png 25
after that i just want the position in this query ,means
suppose i am logged in ,in the website and my id is 1 ,so i want the Rank also in this table means the result should be like this:
future_user_type_id name profile_img Points Rank
2 b b.png 40 1
1 a a.png 25 2
so please provide me the proper query to solve this
thanks in advance............