SQL SERVER里以时间为条件进行的查询(50分)

smoking的方法是把所有的工作都交给后台!这样的结果很可怕哦!这样的查询你是知道后果的!
还有个办法可以考虑一下!就是做临时表!
select * #tmp from table where date>1 and date<2
select * from #tmp where time>1 and tim<2
2次查询搞定!没后遗症!不过temp数据库要足够大
 
如果怕增加服務器的負擔的話,先執行如下簡單查詢:
Select * from table1 where (buytime between '2002-01-01' and '2002-06-30')
再在Query中用篩選來實現吧:
procedure TForm1.Query1FilterRecord(DataSet;Var Accept:Boolean);
begin
Accept:=Query1.FieldByName('Buytime').AsTime>StrToTime('08:00:00')
And Query1.FieldByName('BuyTime').AsTime<StrToTime('10:00:00');
end;
這樣效率可能比較高.
 
to jobsxy:
在where条件里面,你在把字符窜转换成时间,在用一个between and 不久可以了吗?
 
执行SQL命令时,要根据所使用的数据库种类的不同而实用不同的语法格式。
在Access数据库的语法格式为:
select * from man where birthday=#1995/3/1#
Microsoft SQL Server 数据库的语法格式:
select * from man where birthday='1995/3/1'
 
多人接受答案了。
 
顶部