# Problem with ranking users

**URL:** <https://forum.kirupa.com/t/problem-with-ranking-users/307449>\
**Category:** programming\
**Created:** [April 3, 2010, 4:05pm UTC](https://forum.kirupa.com/t/problem-with-ranking-users/307449 "2010-04-03T16:05:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![keithjarrett](https://avatars.discourse-cdn.com/v4/letter/k/bbe5ce/32.png) [@keithjarrett](https://forum.kirupa.com/u/keithjarrett)\
**Post date:** [April 3, 2010, 4:05pm UTC](https://forum.kirupa.com/t/problem-with-ranking-users/307449/1 "2010-04-03T16:05:30Z")

</div>

Hi, I want to rank my users for a high score.

I tried putting this query in MySQL:

```auto
$sql = 'SELECT * FROM users ORDER BY points DESC, username ASC LIMIT 20';

```

but got this reply:

```auto
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '$sql = 'SELECT * FROM users ORDER BY points DESC, username ASC LIMIT 20'' at line 1

```

What have I done wrong? the table is called users and there is username and points in it.

Also, I’ve tested a few other queries with success, but I don’t know how to actually show the ranking in a .php page. And I’ve looked everywhere and can’t get an explanation of this.

Thanks
