Returning results in the order of 'most results first'

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
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Returning results in the order of 'most results first'

Post by Grim... »

Well, the subject made no sense :?

Anyway, let's say I had a forum, which, in the 'posts' table, lists the text, and the poster id.

I want to see who has made the most posts, so I need to fetch a list of the poster id's, ordered by the amount of times they are in the table.

And that's where my SQL skills fail me. All I can do is

Code: Select all

SELECT * FROM women WHERE attracted_to = 'Grim...' ORDER BY boob_size DESC
:D
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Code: Select all

SELECT COUNT(ID) as id FROM TABLE GROUP BY USER_ID ORDER BY id DESC
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

look at the having clause...
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Returning results in the order of 'most results first'

Post by Chris Corbyn »

Grim... wrote:

Code: Select all

SELECT * FROM women WHERE attracted_to = 'Grim...' ORDER BY boob_size DESC
:lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol:
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

Ta :)
Post Reply