MySQL SQL数据排名查询某条数据是总数据的第几条
程序员文章站
2022-03-31 09:30:45
查询所有数据排名
SELECT a.yhid,a.zjf,a.dqjf,(@rowno:=@rowno+1) as rowno
FROM jfxt_yhjfxx a,(s...
查询所有数据排名
SELECT a.yhid,a.zjf,a.dqjf,(@rowno:=@rowno+1) as rowno FROM jfxt_yhjfxx a,(select (@rowno:=0)) b ORDER BY a.zjf DESC
指定查询某条数据的排名
SELECT * FROM ( SELECT a.yhid,a.zjf,a.dqjf,(@rowno:=@rowno+1) as rowno FROM jfxt_yhjfxx a,(select (@rowno:=0)) b ORDER BY a.zjf DESC) c WHERE c.yhid='f531aded-bd09-4574-8826-4482bd918f91'