比如
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`)
慕码人2483693
相关分类