Learn PHP in 17 Days

Easy, non-nonsense guides to learning php. 47 lessons in total - click to get your copy of these fantastic guides.

MySQL Random Row

To get a random row from your table, you can use the following trick:


SELECT * FROM myTable ORDER BY RAND() LIMIT 1
This will return a single random row from myTable.

Keep in mind you can also use a WHERE clause to limit the set you are choosing a random record from.

This is a more efficient way of finding a random result than it would be if you returned all the records from the table and looped through them in your code.

Are you a Developer, Designer or Copy Writer? Or Looking For One?

Click here to see 100s of jobs updated every day that you can complete to earn good money. Also find that programmer, designer or copy writer you have been looking for - advertise and get the best guy for your job - click here to find out more

Leave a Reply

Make $100,000/Month - Every Month!

It Works! We Make Our Customers Millionaires! Act now and get $600 bonus and a Free Money Making Website! - click to get started