我想查一下,当天时间时间是否在数据库里开始和结束的时间段内!
CREATE TABLE `teache_class` (
`id` int(11) NOT NULL auto_increment COMMENT '自增ID',
`class_name` varchar(255) collate utf8_unicode_ci NOT NULL COMMENT '班级名称',
`time_start` datetime NOT NULL COMMENT '开始时间',
`time_end` datetime NOT NULL COMMENT '结束时间',
`state` int(11) NOT NULL COMMENT '状态',
`reg_time` datetime NOT NULL COMMENT '注册时间',
`applicants` int(11) NOT NULL COMMENT '注册人',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1; INSERT INTO `teache_class` (`id`, `class_name`, `time_start`, `time_end`, `state`, `reg_time`, `applicants`) VALUES
(1, 'test2', '2010-06-10 00:00:00', '2010-06-13 00:00:00', 1, '2010-06-11 22:33:41', 133);
我想知道 select * from teache_class where 当前时间 在 time_start 和 time_end 之间请各位师哥帮忙解答!
CREATE TABLE `teache_class` (
`id` int(11) NOT NULL auto_increment COMMENT '自增ID',
`class_name` varchar(255) collate utf8_unicode_ci NOT NULL COMMENT '班级名称',
`time_start` datetime NOT NULL COMMENT '开始时间',
`time_end` datetime NOT NULL COMMENT '结束时间',
`state` int(11) NOT NULL COMMENT '状态',
`reg_time` datetime NOT NULL COMMENT '注册时间',
`applicants` int(11) NOT NULL COMMENT '注册人',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1; INSERT INTO `teache_class` (`id`, `class_name`, `time_start`, `time_end`, `state`, `reg_time`, `applicants`) VALUES
(1, 'test2', '2010-06-10 00:00:00', '2010-06-13 00:00:00', 1, '2010-06-11 22:33:41', 133);
我想知道 select * from teache_class where 当前时间 在 time_start 和 time_end 之间请各位师哥帮忙解答!
select * from teache_class where now() between time_start and time_end