比如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_UNIXTIME(UNIX_TIMESTAMP(add_time),'%h')>=8 AND FROM_UNIXTIME(UNIX_TIMESTAMP(add_time),'%h')<12 GROUP BY CONVERT(add_time,CHAR(10))表结构:`mem_id` int(10) unsigned NOT NULL AUTO_INCREMENT, `mem_name` varchar(50) NOT NULL , `mem_pass` varchar(50) NOT NULL , `telephone` varchar(20) 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`)
1 回答
慕码人2483693
TA贡献1860条经验 获得超9个赞
SELECT * FROM table_nameWHERE time BETWEEN unix_timestamp(2012-12-11 8:00:00) AND unix_timestamp(2012-12-11 12:00:00)OR time BETWEEN unix_timestamp(2012-12-12 8:00:00) AND unix_timestamp(2012-12-12 12:00:00)OR time BETWEEN unix_timestamp(2012-12-13 8:00:00) AND unix_timestamp(2012-12-13 12:00:00)
添加回答
举报
0/150
提交
取消