Top Ten Results

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
EricS
Forum Contributor
Posts: 183
Joined: Thu Jul 11, 2002 12:02 am
Location: Atlanta, Ga

Top Ten Results

Post by EricS »

I'm trying to write a mysql command that will find the top ten, and only the top ten results from a search. Here is the code i tried:

Code: Select all

SELECT Name,NumberSold FROM PRODUCT ORDER BY NumberSold LIMIT 10
What I want is the top ten sold items, what Im getting is the first 10 items in that tables ordered by number of sold.

Also, I only want 10 returned if that's possible.

Thanks in advance.

Eric Stewart[/quote]
kitsch
Forum Newbie
Posts: 12
Joined: Mon Nov 11, 2002 3:29 pm

Post by kitsch »

Try this:

Code: Select all

SELECT Name,NumberSold FROM PRODUCT ORDER BY NumberSold DESC LIMIT 10
EricS
Forum Contributor
Posts: 183
Joined: Thu Jul 11, 2002 12:02 am
Location: Atlanta, Ga

How did I miss that

Post by EricS »

Thanks, I hate making such stupid mistakes. :roll:

Worked great kitsch.

Eric Stewart
Post Reply