Page is a not externally linkable
- Code, Content, and Presentation
-- Databases
---- Mysql - How to select a random row?


asahmed - 11:00 pm on Jul 22, 2010 (gmt 0)


Hello world :)

Does anybody know the best way to select a random row from a Mysql table?


I've been using the following query until someone told me that it is not the best in term of performance. especially on big tables..
SELECT * from my_table ORDER BY RAND() LIMIT 1


Any suggestions or alternative ways to select a random record?


Thread source:: http://www.webmasterworld.com/databases_sql_mysql/4175055.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com