How to retrieve highest 10 numbers

Codes here !

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 6
Joined: Mon Apr 23, 2012 2:33 pm

Thu Apr 26, 2012 2:00 pm

Im working on a table were it displays the top 10 users on the site. Their reputation is based on a number so how do I find the 10 highest numbers in a table?

Once I figure out my answer I will post back to help others in the future.

User avatar
New php-forum User
New php-forum User
Posts: 236
Joined: Sat Apr 14, 2012 11:57 am
Location: Vilnius, Lithuania

Thu Apr 26, 2012 2:18 pm

You would need to order number column from highest to lowest value and select first 10 rows.

For that you should check out ORDER BY optimization and LIMIT optimization for SELECT sentence.

User avatar
php-forum GURU
php-forum GURU
Posts: 2192
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Fri Apr 27, 2012 4:17 am

SELECT * FROM table ORDER BY column LIMIT 10

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest