开发者

How to build FourSquare like leaderboard (users above and below you)

I'm looking for a way to implement Foursquare's style of le开发者_开发问答aderboard where instead of showing you the top 10 for example it shows the you 2 people above you and 2 people below you between your friends.

I'm hoping to avoid having to pull down everyones scores and do some array manipulation. Is there anyway I can do this with a smart SQL statement?


You could (assuming table USER has an integer column SCORE):

select * from USER where SCORE < myscore order by SCORE DESC limit 2;

select * from USER where SCORE >= myscore order by SCORE ASC limit 2;

Is this what you mean?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜