22,302
社区成员




select * from ( select * from Login201511 union all select * from Login201512)x
where Explain like '%%' and Contents like '%%' and Id not in(
select top 0 Id from ( select * from Login201511 union all select * from Login201512) y
where Explain like '%%' and Contents like '%%'
and DATEDIFF(SECOND,'2015-11-01 16:34:42',time)>=0
and DATEDIFF(SECOND,time,'2015-12-01 16:34:51')>=0
order by time desc,Id desc )
and DATEDIFF(SECOND,'2015-11-01 16:34:42',time)>=0
and DATEDIFF(SECOND,time,'2015-12-01 16:34:51')>=0
order by time desc,id desc
--1. 请务必在time列上加索引。
--2. 更改如下条件:
and DATEDIFF(SECOND,'2015-11-01 16:34:42',time)>=0
and DATEDIFF(SECOND,time,'2015-12-01 16:34:51')>=0
--改为:
and time>='2015-11-01 16:34:42' and time <='2015-12-01 16:34:51'