Ordering a Select statement with rand()
What I have is
select from .... where ... and .... and ... order by RAND() limit ...
which works fine, but what I want to do and can't find the answer anywhere is to order the order by, something like
... order by cup, coffee RAND() limit ...
so all the cups are displayed first and then the coffee is randomly displayed. Without the rand() it works. I tried GROUP BY cup but no go either.
Short of two queries, any ideas?
druagord posted this at 00:07 — 15th July 2004.
He has: 335 posts
Joined: May 2003
Just a tought but did you try
order by cup, RAND() limit ...
Busy posted this at 01:51 — 15th July 2004.
He has: 6,151 posts
Joined: May 2001
Well what do you know, it worked
Thanks druagord
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.