0

So I have this line of code:

$results = mysql_query('SELECT * FROM members WHERE category1="Photographers" ORDER BY premium DESC, featured DESC, company ASC');

Everything works great, Premium members show up above featured. Featured above regular members, and they are all in alphabetical order. However I want to have featured members randomized and not in alphabetical order. I have tried RAND() but it randomizes all my members, please help.

Edited by Travus

3
Contributors
5
Replies
29
Views
4 Years
Discussion Span
Last Post by Travus
0

Could you give me a code example? I keep getting the error "Incorrect usage of UNION and ORDER BY". Obviously I am using it wrong but I am not sure how.

0

Cutting out "featured DESC" makes the featured members get mixed with regular members and that is not what I want. What I want is to have something like this:

Premium Member
Featured Member Rand()
Normal Member Alphabetical

Thanks for your reply.

1

I found a solution on the web. Thanks for everyones help!

SELECT * 
FROM members 
WHERE category1="Photographers" 
ORDER BY 
    premium DESC, 
    featured DESC, 
    CASE WHEN featured = 1 THEN RAND() ELSE company END ASC
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.