导航:
论坛 -> 数据库专区
斑竹:liumazi,waterstone
作者:
2004/4/16 11:05:43
标题:
help,请教一个关于sql语句的问题。在线等。先谢了:)
浏览:1801
加入我的收藏
楼主:
使用access数据库 在查询的时候,我这样写的 str:string; ..... str:='select * from tableps where psid = 123'; ..... 这样可以得出我需要的结果;但是如果我想要动态的查询,比如说我定义了一个integer型的变量j,想要查找出j,应该怎么写呢? 我这样试的, str:='select * from tableps where psid = 'j; 显然啦,不行,希望大家告诉我这个格式应该怎么写。 谢谢。
----------------------------------------------
我是一个新人,希望能得到ggjj的帮助。 为生活所迫,需要学习delphi,但是这段经历会成为我成长的记忆; 大家的帮助则是我这段时间里最温暖的记忆 click here to my blog
作者:
2004/4/16 12:25:57
1楼:
str:='select * from tableps where psid = '+ IntToStr(j);
----------------------------------------------
-广袤璀璨的银河,永无止境的梦想(梦无止境游银河) 博客挂了……
作者:
2004/4/16 12:33:28
1楼:
要么用参数,要么这样写 'select * from tableps where psid = '+inttostr(j);
----------------------------------------------
我来自农村广阔的田野我的每一个动作都很夸张http://waterstone.51r.com
作者:
mm777 (mm)
★☆☆☆☆
-
盒子活跃会员
2004/4/16 14:31:07
2楼:
with query1 do begin With SQL do begin Clear; Add('select * from tableps where psid=:p1'); end; Close; unparepar; parambyname('p1').AsInteger:=j; parepar; open; end;
----------------------------------------------
-
作者:
endo (燕子帝国)
★☆☆☆☆
-
盒子活跃会员
2004/4/16 15:37:26
3楼:
强烈建议楼主看看书先!!!
----------------------------------------------
『惠安人才网』 www.harcw.net
作者:
2004/4/17 9:18:51
4楼:
还可以: var i:integer; begin ... query.sql.text:=format('select * from tableps where psid=%d',[i]") ... end;
----------------------------------------------
...反正我信了