Bluehost.com Web Hosting $6.95

removing the neccessity for a perl-script with a query

This is a discussion on removing the neccessity for a perl-script with a query within the MySQL Database forums, part of the Database Forums category; Hi, I have the following construction: for($hour=0; $hour<24; $hour++) { do_query("SELECT COUNT(*) AS n, wind_direction ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-23-2007
Folkert van Heusden
 
Posts: n/a
Default removing the neccessity for a perl-script with a query

Hi,

I have the following construction:

for($hour=0; $hour<24; $hour++)
{
do_query("SELECT COUNT(*) AS n, wind_direction FROM data WHERE
windspeed > 0 AND HOUR(timestamp)=$hour GROUP BY wind_direction ORDER BY n
DESC LIMIT 1");
...
}

as you can see, I execute a query for each hour in a day.
Now I was wondering: can I somehow remove the for-loop and let the database
do all the work? e.g. a query which automatically processes al 24 hours

--
--------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:31 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0