Monday, September 24, 2012

HOW TO SELECT RANDOM ROWS IN MYSQL

To select random rows from your table with limiting how many rows to return. The easiest way to generate random rows in MySQL is to use the ORDER BY RAND() clause
SELECT col1 FROM tbl ORDER BY RAND() LIMIT 10;

No comments:

Post a Comment