Good morning, Willy -

If you're using some sort of scripting language, like PHP, this would be
easily done by starting a variable at the beginning of the date range, then
repeating the below query and incrementing the variable by 10 minutes each
time through a while loop until you've passed the other end of the date
range.

Something like this:

$date = '01-01-2007 00:00:00';
while ($date <= '01-02-2007 23:59:59') {

SELECT * FROM my_table
WHERE id IN
( SELECT id FROM my_table
WHERE datefield >= "$date"
AND datefield < DATE_ADD($date, INTERVAL 10 MINUTE) )
ORDER BY RANDOM
LIMIT 1

$date = $date + (php function to add 10 minutes);

}

I'm not a PHP whiz but hopefully you get the idea.

Dan


On 8/12/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hi,
> I have a table with records dated 01-01-2007 00:00:00 to 01-02-2007
> 23:59:59. What I want to do is grab 1 random record in every 10 minutes
> between the date. Please help me.
>
> Regards,
>
>
> Willy
> --
> www.sangprabv.web.id
> www.binbit.co.id
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
>
>

Reply via email to