Did you know? DZone has great portals for Python, Cloud, NoSQL, and HTML5!
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

Snippets has posted 5886 posts at DZone. View Full User Profile

Simple Query To Select N Random Rows

04.08.2005
Email
Views: 34218
  • submit to reddit
        A very simple, if not particularly portable or fast, quest for selecting a set of random rows from MySQL.
SELECT * from my_table ORDER BY RAND() LIMIT 25
I use this a lot when testing.