Use a subquery:
SELECT * FROM
(
SELECT * FROM users ORDER BY rand() LIMIT 20
) T1
ORDER BY name
The inner query selects 20 users at random and the outer query orders the selected users by name.
More Related Contents:
- MySQL: Select Random Entry, but Weight Towards Certain Entries
- Selecting all fields except only one field in mysql [duplicate]
- Using PHP data in MySQL [closed]
- which is better every user have a table or just a row [closed]
- PHP – Change value y,n in database [closed]
- PDOException SQLSTATE[HY000] [2002] No such file or directory
- Many-to-many relationships examples
- strange character encoding of stored data , old script is showing them fine new one doesn’t
- Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in
- How to upload images into MySQL database using PHP code
- PDO mysql: How to know if insert was successful
- How to loop through a mysql result set
- MySQL check if a table exists without throwing an exception
- Maximum execution time in phpMyadmin
- Mysql No connection could be made because the target machine actively refused it
- Replacing mysql_* functions with PDO and prepared statements
- Selecting all columns that start with XXX using a wildcard?
- Is there any way to check the performance of mysql Indexing
- IP address storing in MySQL database using PHP [duplicate]
- phpmyadmin automatic logout time
- unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING error [duplicate]
- MySQL skipping first row
- Using LIKE in bindParam for a MySQL PDO Query [duplicate]
- How do I set the selected item in a drop down box
- Fatal error: Call to undefined function mysqli_result()
- Laravel nested relationships
- select within 20 kilometers based on latitude/longitude
- mysqli – fetch_Array error call to a member function fetch_array() on a non-object mysqli [duplicate]
- Auto Increment skipping numbers?
- Mysqli multiple row insert, simple multi insert query [duplicate]