Wednesday, June 4, 2008

How to select a random row from mysql table

Are you looking a way to get a random record from a mysql table?, want to do it by single and a simple query? if the answer is yes, here it is


SELECT * FROM table_name ORDER BY RAND() LIMIT 0,1



You can use mysql rand() function to easily get a random data row.
but be warned that for large data tables this function is said to be slow.

If you like to learn more about SLIIT please visit www.sliit.lk

 Subscribe To My Blog

No comments:

Post a Comment