Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.