mysql 中,统计一个时间段内每天8时到12时的数据的查询语句怎么写?
澳门赌场开户
澳门赌场开户
当前位置 : 澳门赌场开户 > 在线博彩导航

mysql 中,统计一个时间段内每天8时到12时的数据的查询语句怎么写?

比如
2012-12-11 8:00:00-12:00:00

2012-12-13 8:00:00-12:00:00
这3天内,8点到12点。
查询语句怎么写?

自己写出来了。

EXPLAIN SELECT COUNT* FROM fd_member WHERE FROM_UNIXTIMEUNIX_TIMESTAMPadd_time,%h>=8 AND FROM_UNIXTIMEUNIX_TIMESTAMPadd_time,%h<12 GROUP BY CONVERTadd_time,CHAR10

不过,性能是个问题,谁有更好的办法。
表结构:

`mem_id` int10 unsigned NOT NULL AUTO_INCREMENT,
  `mem_name` varchar50 NOT NULL ,
  `mem_pass` varchar50 NOT NULL ,
  `telephone` varchar20 DEFAULT NULL,
  `add_time` timestamp NULL DEFAULT NULL,
  PRIMARY KEY `mem_id`,
  UNIQUE KEY `mem_card_id` `mem_card_id`,
  UNIQUE KEY `mem_name` `mem_name`
SELECT * FROM table_name
WHERE time BETWEEN unix_timestamp2012-12-11 8:00:00 AND unix_timestamp2012-12-11 12:00:00
OR time BETWEEN unix_timestamp2012-12-12 8:00:00 AND unix_timestamp2012-12-12 12:00:00
OR time BETWEEN unix_timestamp2012-12-13 8:00:00 AND unix_timestamp2012-12-13 12:00:00

栏目列表

广告位

澳门赌场开户