Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用这样的查询来建立我的排名:
SELECT * FROM users ORDER BY fame DESC;
我通过在行循环中增加一个变量来计算位置
我想在我的个人资料子页面中添加一个排名位置,而不是先获取所有排名。
我想加入两个查询,但我不知道如何实现这个......
尝试这样的事情。
SELECT @rownr := @rownr + 1 AS row_number, users.* FROM users JOIN (SELECT @rownr := 0) r ORDER BY fame DESC;