这SQL有什么不对

test2001 2001-11-07 07:13:04
aa:=maskedit1.text;
bb:=maskedit2.text;

SQL.Add('select * from table where field1='''+Combobox.Text+''' and between(filed2,aa,bb');

谢谢
...全文
115 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
xBai21 2001-11-07
  • 打赏
  • 举报
回复
field2 是什么字段?
lxl 2001-11-07
  • 打赏
  • 举报
回复
SQL.Add('select * from table where field1='''+Combobox.Text+''' and field2 between '''+aa+''' and '''+ bb'''');
腊月三毛 2001-11-07
  • 打赏
  • 举报
回复
with query1 do
begin
close;
sql.clear;
SQL.Add('select * from table where field1='''+Combobox.Text+''' and field2 between :aa and :bb');
parambyname('aa') .value:=值1;
parambyname('bb') .value:=值2;
prepare;
open;
end;
如果是ADO控件同理
test2001 2001-11-07
  • 打赏
  • 举报
回复
to xBai21(小新) 
语法没错,但(between :aa and :bb)好象没作用,找不到记录
to breezing(网上的小鱼) 
能写出来吗

连的是ACCESS
breezing 2001-11-07
  • 打赏
  • 举报
回复
你连的是什么数据库?
breezing 2001-11-07
  • 打赏
  • 举报
回复
不用between,用>和<试试,其实实现一个语句有很多种办法。
xBai21 2001-11-07
  • 打赏
  • 举报
回复
SQL.Add('select * from table where field1='''+Combobox.Text+''' and field2 between :aa and :bb');
Open;
Parameters[0].Value:= aa // aa的值
Parameters[1].Value:= bb // bb的值
test2001 2001-11-07
  • 打赏
  • 举报
回复
to hfclql(三毛) 
报参数AA没有缺省值,请指点

SQL.Add('select * from table where field1='''+Combobox.Text+''' and between(filed2,aa,bb)');

breezing 2001-11-07
  • 打赏
  • 举报
回复
括号位置,还有你的加号是干什么的?
腊月三毛 2001-11-07
  • 打赏
  • 举报
回复
SQL.Add('select * from table where field1='''+Combobox.Text+''' and field2 between aa and bb');

5,939

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧