To randomly select a row from a MySql table, use the following:
SELECT * FROM tableName ORDER BY RAND() LIMIT 1
The RAND() function will randomly sort the selected data. The LIMIT X will select the first X data rows. In this example, X equals 1, so it is the equivalent to one row randomly selected. If you want to randomly select more than one row, set X to the number of random rows you want to retrieve.
RSS Feed
Posted in
Tags: 
