TypechoJoeTheme

Dcr163的博客

统计

Mysql实现排行榜sql语句

2022-05-13
/
0 评论
/
1,078 阅读
/
正在检测是否收录...
05/13

Mysql实现排行榜sql语句

直接上代码

-- 按余额查询排行榜
SELECT
    m.id,
    m.nickname,
    m.openid,
    m.avatar,
    @rownum := @rownum + 1 AS rownum 
FROM
    ( SELECT @rownum := 0 ) r,
    ( SELECT * FROM `tbl_member` WHERE credit> 0 ORDER BY credit DESC, created_at DESC ) AS m
    
    

-- 查询某个用户的余额 排行名词
SELECT
    * 
FROM
    (
SELECT
    m.id,
    m.nickname,
    m.openid,
    m.avatar,
    @rownum := @rownum + 1 AS rownum 
FROM
    ( SELECT @rownum := 0 ) r,
    ( SELECT * FROM `tbl_member` WHERE credit> 0 ORDER BY credit DESC, created_at DESC ) AS m
    ) AS rankTable 
WHERE
    rankTable.openid = 'xxxxiilkjdlkj;flkj;lkkkks'
MYSQL排行榜
朗读
赞(0)
版权属于:

Dcr163的博客

本文链接:

https://dcr163.cn/648.html(转载时请注明本文出处及文章链接)

评论 (0)

人生倒计时

今日已经过去小时
这周已经过去
本月已经过去
今年已经过去个月

最新回复

  1. William Tardent
    2024-02-27
  2. Maryann Hamer
    2024-02-27
  3. Sanora Pantano
    2024-02-24
  4. aa
    2024-02-21
  5. Kassie Baum
    2024-01-28

标签云