MySQL ORDER BY rand(), name ASC

Posted by Josh K on Stack Overflow See other posts from Stack Overflow or by Josh K
Published on 2010-05-21T13:55:39Z Indexed on 2010/05/21 14:00 UTC
Read the original article Hit count: 205

Filed under:
|
|
|
|

I would like to take a database of say, 1000 users and select 20 random ones (ORDER BY rand(),LIMIT 20) then order the resulting set by the names. I came up with the following query which is not working like I hoped.

SELECT * FROM users WHERE 1 ORDER BY rand(), name ASC LIMIT 20

© Stack Overflow or respective owner

Related posts about mysql

Related posts about select