Jump to content

[SOLVED] ORDER BY most popular


Canman2005

Recommended Posts

Hi all

 

I have a table called `members` which looks like

 

id

user_id

type

 

I want to do a simple

 

SELECT `user_id` FROM `members` WHERE `type` = 'J'

 

My question is.

 

How can I get the QUERY do the ORDER BY most popular, using the `user_id` and LIMIT it by 3

 

So if there are

 

9 rows with `user_id` value set as 3

28 rows with `user_id` value set as 7

2 rows with `user_id` value set as 13

55 rows with `user_id` value set as 18

 

then the QUERY would return `user_id` in the following order

 

`user_id`

18 (as it has 55 rows)

7 (as it has 28 rows)

3 (as it has 9 rows)

 

Any help would be great, been hunting for an answer for the last 4 hours with no luck

 

thanks very much in advance

 

dave

Link to comment
https://forums.phpfreaks.com/topic/172368-solved-order-by-most-popular/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.