005: MySQL – Selecting a set of random rows from a table

The following SQL select 5 random rows from database tables in MySQL.

SELECT myColumns FROM mytable ORDER BY RAND() LIMIT 5

Blog Widget by LinkWithin

Originally posted 2007-11-18 14:41:34.

Share