Reputation: 13
I'm trying to display how many users my site gets for each hour of the day. I've come up with this, it works but...
$time = mysql_query("SELECT * FROM track_log WHERE time>='{$date} 00:00:00' AND
time<='{$date} 01:00:00'");
$hour = mysql_num_rows($time);
before I do this 23 more times is there a better way to get the results for each hour?
Upvotes: 0
Views: 60
Reputation: 204746
SELECT hour(`time`) as hour_of_day, count(*)
FROM track_log
group by hour_of_day
Upvotes: 4