A handy tip to choose random record from mySQL

Published 24 April 05 06:30 PM

select * from TABLE where active = 'Y' and online = 'Y' order by rand() limit 0,1

This query will return a random record from the table.

I needed it to display a random quote on a website.

Happy mySQL-ing!

 

A lot of power fluctuations today. I hate WAPDA. When I pay them more then they deserve, then why don't they do what they are supposed to do?

by fahad
Filed under:
Anonymous comments are disabled