dragon0023 2013-08-26 19:50
浏览 14
已采纳

显示一天mysqli查询的每小时点击次数

I have the following table:

CREATE TABLE `visitors_table` (
`ID` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`visitor_ip` VARCHAR(32) NULL,
`visitor_browser` VARCHAR(255) NULL,
`visitor_hour` SMALLINT(2) NOT NULL DEFAULT '00',
`visitor_minute` SMALLINT(2) NOT NULL DEFAULT '00',
`visitor_date` DATE NOT NULL,
`visitor_day` SMALLINT(2) NOT NULL,
`visitor_month` SMALLINT(2) NOT NULL,
`visitor_year` SMALLINT(4) NOT NULL,
`visitor_page` VARCHAR(255) NULL
);

The following query gets the visitors per day:

"SELECT visitor_date FROM visitors_table WHERE visitor_date = CURDATE()";

Now I want output the data hourly. See this example:

Day     Year Hours     Clicks
July 4, 2011 00:00:00  4
July 4, 2011 01:00:00  12 
July 4, 2011 02:00:00  75
July 4, 2011 03:00:00  27

and so on...

Could someone help me? I can't get clear with the output of the total visitors by hours for one day!

With the following query comes only this result:

SELECT visitor_date, count(*) FROM visitors_table WHERE visitor_date = CURDATE() GROUP BY visitor_hour

visitor_date count(*) 
2013-08-31   4
2013-08-31   7

I need to get the results by hours like written as above! Where is my mistake or how can i show it with php?

  • 写回答

1条回答 默认 最新

  • dongmao9217 2013-08-26 19:57
    关注

    SELECT visitor_date, count(*) FROM visitors_table WHERE visitor_date = CURDATE() group by visitor_hour

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集