Skip to content

Instantly share code, notes, and snippets.

@apphp-snippets
Last active December 12, 2015 09:39
Show Gist options
  • Save apphp-snippets/4753309 to your computer and use it in GitHub Desktop.
Save apphp-snippets/4753309 to your computer and use it in GitHub Desktop.
Here the simplest way of selecting random rows from the MySQL database with using "ORDER BY RAND()" clause in the query.
-- source: http://www.apphp.com/index.php?snippet=mysql-selecting-random-row
SELECT * FROM TABLE
ORDER BY RAND()
LIMIT 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment