如何从表table 中查询出这样的记录???name shi_date end_date
客户 2006-5-1 2006-6-1
客户 2006-6-1 2006-7-1
记者 2006-8-1 2006-8-3Edit1,Edit2中的文本都为日期如何用ADOQuery1的sql语句选出Edit1.Text在shi_date与end_date之间或Edit2.Text在shi_date与end_date之间,SQL语句应如何写???这样写查询不出记录
--------------------------------------------------------------------------
ADOQuery1.Close;
ADOQuery1.SQL.Add('select * from table where '''+FormatDateTime('yyyy-m-d',StrToDate
(Edit1.Text))+''' >= shi_date and '''+FormatDateTime('yyyy-m-d',StrToDate
(Edit1.Text))+''' <=end_date or '''+FormatDateTime('yyyy-m-d',StrToDate(Edit2.Text))
+''' >= shi_date and '''+FormatDateTime('yyyy-m-d',StrToDate(Edit2.Text))+'''
<=end_date ');
ADOQuery1.Parameters.ParamByName('c_id').Value:=Edit3.Text;
ADOQuery1.Parameters.ParamByName('p_id').Value:=Edit4.Text;
ADOQuery1.Open;
--------------------------------------------------------------------------
这样写对不对,应该怎样写???
客户 2006-5-1 2006-6-1
客户 2006-6-1 2006-7-1
记者 2006-8-1 2006-8-3Edit1,Edit2中的文本都为日期如何用ADOQuery1的sql语句选出Edit1.Text在shi_date与end_date之间或Edit2.Text在shi_date与end_date之间,SQL语句应如何写???这样写查询不出记录
--------------------------------------------------------------------------
ADOQuery1.Close;
ADOQuery1.SQL.Add('select * from table where '''+FormatDateTime('yyyy-m-d',StrToDate
(Edit1.Text))+''' >= shi_date and '''+FormatDateTime('yyyy-m-d',StrToDate
(Edit1.Text))+''' <=end_date or '''+FormatDateTime('yyyy-m-d',StrToDate(Edit2.Text))
+''' >= shi_date and '''+FormatDateTime('yyyy-m-d',StrToDate(Edit2.Text))+'''
<=end_date ');
ADOQuery1.Parameters.ParamByName('c_id').Value:=Edit3.Text;
ADOQuery1.Parameters.ParamByName('p_id').Value:=Edit4.Text;
ADOQuery1.Open;
--------------------------------------------------------------------------
这样写对不对,应该怎样写???
解决方案 »
- cxgrid焦点问题
- 我的程序效率很低(详见内容),高手帮忙看一下
- 为什么delphi下DBGrid的Column能改长度,但是delphi7下DBGrid的Column不能改长度?
- 如何联接数据库?急!!!!!!
- 我想在WIN32程序里调用DOS中断,该怎么办?100分
- 无法为更新行集定位:一些值可能已在最后读取后改变“请问应何解决
- 如何建立声音文件?(即录音)
- 这个sql查询语句怎么写?
- fengerfeifei(风儿飞飞)在哪?
- 如何用Delphi对DBF文件做简单查询(不用BDE)
- 动态创建一个TDatabase, free后,内存怎么回收呢?
- how can I use the date which in one table to change other tables
(Edit1.Text))+''' BETWEEN shi_date and end_date)or('''+FormatDateTime('yyyy-m-d',StrToDate(Edit2.Text))
+''' BETWEEN shi_date and end_date)');