本帖最后由 xroha 于 2013-07-02 21:04:53 编辑

解决方案 »

  1.   

    期待大神。
    我觉得貌似sql实现不了这位仁兄的需求。
      

  2.   

    需要配合php,
    先order by,然后整个排序后的结果取出,得到结果集,转为二维数组(因为只有一列,故可以做成一维的),然后循环取值判断,看看哪个下标对应值等于指定值,取出下标即可。
      

  3.   

    select count(*) from table where itemid<=(select itemid from table where credits=21 limit 1);itemid 为主键id
      

  4.   

    select count(*) from table where credits>=21