DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Chara has posted 50 posts at DZone. View Full User Profile

Selecting a Random Row from Table in MySQL

02.13.2013
| 5201 views |
  • submit to reddit
-- source: http://www.apphp.com/index.php?snippet=mysql-selecting-random-row
SELECT * FROM TABLE
ORDER BY RAND()
LIMIT 1

  Here the simplest way of selecting random rows from the MySQL database with using "ORDER BY RAND()" clause in the query.

Comments

Akash Deep replied on Tue, 2013/04/23 - 1:29am

thanks !

Femmes Yossef replied on Mon, 2013/04/15 - 10:17am

thank you good job

Michael Molo replied on Wed, 2013/02/20 - 9:30pm