At 08:59 PM 2/27/2010, you wrote:
Hello everyone,

How would I select a random row that changes daily?

Thanks

The common way would be to do:

select * from table order by rand() limit 1;

You can of course add a Where clause to select only those rows that were added today.

select * from table where Log_Date=Date(Now()) order by rand() limit 1;

This works fine as long as there are not too many dates to sort. Otherwise you will need to use an autoinc column and choose one of those randomly. This is not as easy as it looks because the sequence may have holes in it and may not be in the proper sequence.


Mike


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=arch...@jab.org

Reply via email to