select form Table where publictime>'20081010 00:00:00' And publictime<'20081011 00:00:00'select * from date_time where starttime>='2006-6-20 00:00:00' and startti me<='2006-7-01 23:59:59';
select * from table where publictime between "20081010 00:00:00" and "20081011 00:00:00"
select * from table where publictime between "20081010 00:00:00" and "20081011 00:00:00"
怕自己写时间日期常量格式写错那就用 java.sql.PreparedStatement.setTimestamp 方法吧,相应 SQL 改为: SELECT * FROM your_table WHERE publictime BETWEEN ? AND ?
me<='2006-7-01 23:59:59';
SELECT * FROM your_table WHERE publictime BETWEEN ? AND ?
>= ? <= ?
更灵活,从来不用BETWEEN
经测试海量数据 sqlserver库
用between慢
因为between要比较两次。
是&的意思
而非between是&&的意思
select * from table where publictime between (开始时间) and (结束时间)