MySQL SQL 数据排名查询某条数据是总数据的第几条

查询所有数据排名

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'
posted @ 2017-08-24 17:35  夜月光雾  阅读(7)  评论(0编辑  收藏  举报