SQL random rows

To retrieve random rows in SQL you can consider the following SQL queries. It's worth to mention that this option suit small needs best, e.g. 50-100 records/rows. This is in regards to performance.

MYSQL: SELECT * FROM Table ORDER BY RAND() LIMIT 0,100
MSSQL: SELECT TOP 100 * FROM Table ORDER BY RAND()


Written by: Dag Jonny Nedrelid
©2007-2012 http://thronic.com


Feel free to leave a comment.
Name:
URL:
0