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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |