doushangxianq07480 2016-06-29 00:24
浏览 120
已采纳

#1064 - 您的SQL语法出错 - RANK FUNCTION

SELECT RANK() OVER (ORDER BY `point`) FROM `user`

This is my query, I excute it in phpmyadmin, and receive the message:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(ORDER BY `point`) FROM `user` LIMIT 0, 30' at line 1"

I try to find the error but just can't. Please help me!

  • 写回答

1条回答 默认 最新

  • douzai1074 2016-06-29 00:25
    关注

    MariaDB doesn't support window functions. You can do this using a correlated subquery:

    SELECT u.*,
           (SELECT 1 + COUNT(*)
            FROM user u2
            WHERE u2.point < u.point
           ) as rank
    FROM `user` u;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?