模糊查询2 (50分)

  • 主题发起人 主题发起人 fossil
  • 开始时间 开始时间
F

fossil

Unregistered / Unconfirmed
GUEST, unregistred user!
edit1.text-->对应字段aa是 整型
edit2.text-->duiyi字段BB是 字符串
下面语句应该怎么写
sql:='select * from table where aa like????????and bb=???????????
 
真没见过
 
sql:='select * from table where aa =:a and bb like :b'+'%';
parambyname('a').asinteger := strtoint(edit1.text);
parambyname('b').asstring := edit2.text;
 
sql:='select * from table where aa like '+#39+edit1.text+#39+
' and bb like '+#39+edit2.text+#39;
 
他的aa字段是整数啊,这样写还要问吗。
模糊总要先定个整数的“横糊范围”吧,比如在 [min,max]之间?不然怎么写?
 
有点问题
 
要什么都没写清楚...
 
整型类型可以用like吗???
sql:='select * from table where aa like ... and bb='''+edit2.text+'''';
假设aa字段是字符型的
sql:='select * from table where aa like ''%'+edit1.text+''' and.....(同上)

sql:='select * from table where aa like '''+edit1.text+'%'' and bb......'
 
sql:='select * from table where aa =:a and bb like :b'+'%';
parambyname('a').asinteger := strtoint(edit1.text);
parambyname('b').asstring := edit2.text;
个人觉得AA字段应为字符型才好模糊!
 
就是模糊查询吗
如果对一个整数字段来进行模糊查询,查询条件写到EDIT1里面吗
s:='select * FROM TABLE WHERE AA ????
 
老兄,请问一下是什么数据库?
如果是ORACLE:
sql:='select * from table where to_char(aa) like '%edit1.text%' and bb= edit2.text
其实DELPHI本身也有类似函数。
 
[blue][/blue]


mysql:=select * from table_name where aa like :aa and bb like ''%'+Edit2.text+'%'';
Query1.params[0].AsInteger:=StrToInt(Edit1.text);
 
需要你动手试试,如果问题已经解决了,请结束问题。

BTW:不要怪我多嘴啊,帮版主出一份力:)
 
select * from tablename where aa like '+edit1.text+' and
bb like '%'+edit2.text+'%'
 
数值字段也是可以like的,他是把数字转换为字符数据再计算like的
比如 1234.5678 like '%34.56%' ,他是转换为 '1234.5678' like '%34.56%' 计算的。结果是true
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
554
import
I
后退
顶部