query1.SQL.Add('select zhonglei from execuse where empid=:empid
                and date1>=:startdate and date2<=:enddate');
query1.Params[0].AsString:=edit5.Text;
query1.Params[1].AsDateTime:=tt;
query1.Params[2].AsDateTime:=tt;
query1.Prepare;
query1.Open;

解决方案 »

  1.   

    query1.SQL.Add('select zhonglei from execuse where empid=:empid
                    and :date1>=startdate and :date2<=enddate');
    ->>
    query1.SQL.Add('select zhonglei from execuse where empid=:empid
                    and startdate<=:date1 and enddate>=:date2');
      

  2.   

    奇怪,我在sql plus 中可以列名放在条件后面:
    select * from table where sysdate>create_date and sysdate < update_date
    但是delphi就是不行
      

  3.   

    execuse 是保留字,
    改其他試試 
      

  4.   

    execuse是保留字并且写法也不太对。
     应为: 
     query1.SQL.Add('select zhonglei from execuse where    empid=:empid
        and startdate<=:date1 and enddate>=:date2');