我现有表tb_warehouse_detailed 
字段有
billdate      billcode          tradecode
--------------------------------------------
2009-04-03    20090503JH0001    T00001
2009-04-04    20090504JH0002    T00001
2009-04-05    20090505JH0003    T00002
..............................我想实现在时间段(billdate)中查询字段billcode 、tradecode的数据,怎写?请教。
以下只是实现时间段查询,但不能加字段billcode 、tradecode查询?  
var
  sqlstr:string;
  a,b,e:string;
begin
b:=datetostr(DateTimePicker1.date); 
e:=datetostr(DateTimePicker2.date); 
a:='select * from tb_warehouse_detailed where billdate between '+QuoTedStr(b)+' and '+QuoTedStr(e);
with ADOQuery do begin
with sql do begin 
close;
clear;
ADOQuery.sql.Add(a);
end;
open;
DBGrid1.DataSource:=EQDS;
end;

解决方案 »

  1.   

    where后面继续and
    建议多看书
      

  2.   

    什么意思,你不是已经把时间段内的数据都查到了吗,里面不是包括billcode 、tradecode吗
    如果想多字段条件查询,那就加几个And吗
    a:='select * from tb_warehouse_detailed where (billdate between '+QuoTedStr(b)+' and '+QuoTedStr(e)+') and billcode=xxx and tradecode=xxx';
      

  3.   

    我想是加入billcode 、tradecode字段里面的时间段查询?
    DateTimePicker1 DateTimePicker1  edit1   edit2
      

  4.   

    明白了!
    a:='select * from tb_warehouse_detailed where (billdate between '+QuoTedStr(b)+' and '+QuoTedStr(e)+') and (tradecode like'''+'%'+ComboBox1.Text+'%'') and (billcode like'''+'%'+ComboBox2.Text+'%'')';