想知道某条记录的排名,如何实现?
架设我有 order by hits desc,我想知道其中id为123的记录已hits排名时排第几?经常用于歌手名次或专辑名次。

解决方案 »

  1.   

    这个很好做的,在while循环的时候设置一个$i;$i=1 while循环完后$i++  这样所有的排名都会有的。
      

  2.   

    在SQL里用正常查询语句,例如
    select count(*) from table where id>10获得count(*)数,应该就是你说的排名了吧
    如果不是int索引来查找的话,可能就麻烦了
      

  3.   


    select count(*)+1 from biao where hits>(select hits from biao where 
    id=123)
      

  4.   

     
    select   count(*)+1   from   biao   where   hits> (select   hits   from   biao   where   
    id=123)