How to retrieve highest 10 numbers

Codes here !

Moderators: macek, egami, gesf

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

How to retrieve highest 10 numbers

Postby nnjgmatt » 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
minimihi
New php-forum User
New php-forum User
Posts: 238
Joined: Sat Apr 14, 2012 11:57 am
Location: Vilnius, Lithuania

Re: How to retrieve highest 10 numbers

Postby minimihi » 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
egami
php-forum GURU
php-forum GURU
Posts: 2196
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: How to retrieve highest 10 numbers

Postby egami » Fri Apr 27, 2012 4:17 am

SELECT * FROM table ORDER BY column LIMIT 10


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 2 guests