My current code is:
[syntax=php]$sql = "SELECT * FROM juarez WHERE categoriesID = 4 ORDER BY RAND() LIMIT 1";[/syntax]
I need to seed the rand value to something that would make it get a new random row EACH hour, each day, and each week.
each sql query goes in different pages. I dont know where to start, can anybody help me please? I want to display a random row in a page in one page, a daily random in another and a weekly random in another. Please help me
ORDER BY RAND() time interval? Weekly? Daily? Custom?
ORDER BY RAND() time interval? Weekly? Daily? Custom?
Last edited by jacek on Sun Nov 25, 2012 1:35 am, edited 1 time in total.
Reason: code tags...
Reason: code tags...
Re: ORDER BY RAND() time interval? Weekly? Daily? Custom?
Well the RAND() function accepts a seed parameter so you could probably combine it with the date functions
[syntax=sql]ORDER BY RAND(YEAR() * 1000 + WEEK())[/syntax]
for example
Remember that the use of the RAND() function like this is pretty slow for large tables though.
[syntax=sql]ORDER BY RAND(YEAR() * 1000 + WEEK())[/syntax]
for example
Remember that the use of the RAND() function like this is pretty slow for large tables though.