delphi中关于一给模糊查询【很郁闷。。。】

QQ12236822 2009-02-11 11:18:08
 commandtext:='select id from ST_LLD where ZHTH='''+spub_zhth+''' and  ND='''+spub_nd+''' AND DH='''+dhedit.text+'''';


dh后面写 like %  老是弄错 

大家帮帮忙

谢谢
...全文
168 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
ydysnIV 2009-02-16
  • 打赏
  • 举报
回复
commandtext:='select id from ST_LLD where ZHTH='''+spub_zhth+''' and ND='''+spub_nd+''' AND DH='+#39 + '%' +dhedit.text+'%'+#39;
kernel001 2009-02-12
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 zxf_feng 的回复:]
用绑定参数比较好,比拼SQL简单
sql.text := 'select id from st_lld where zhth=:zhth and nd=:spub_nd and dh like :db';
parameters.parambyname('zhth').value := '';
....
[/Quote]

支持
DMU_WD 2009-02-12
  • 打赏
  • 举报
回复
sql语句就是双引号和单引号的游戏 认真点就ok了
阿三 2009-02-12
  • 打赏
  • 举报
回复
用绑定参数比较好,比拼SQL简单
sql.text := 'select id from st_lld where zhth=:zhth and nd=:spub_nd and dh like :db';
parameters.parambyname('zhth').value := '';
....
bdmh 2009-02-11
  • 打赏
  • 举报
回复
commandtext:='select id from ST_LLD where ZHTH='+QuotedStr(spub_zhth)+' and ND='+QuotedStr(spub_nd)+' AND DH='+QuotedStr('%'+dhedit.text);
gzmhero 2009-02-11
  • 打赏
  • 举报
回复
commandtext:='select id from ST_LLD where ZHTH='''+spub_zhth+''' and ND='''+spub_nd+''' AND DH like ''%'+dhedit.text+'''';
火龙岛主 2009-02-11
  • 打赏
  • 举报
回复
commandtext:='select id from ST_LLD where ZHTH='+QuotedStr(spub_zhth)+' and  ND='+QuotedStr(spub_nd)+' AND DH like '+QuotedStr('%'+dhedit.text);
mandarin 2009-02-11
  • 打赏
  • 举报
回复
引号用QuotedStr,看着舒服
hushu02 2009-02-11
  • 打赏
  • 举报
回复
commandtext:='select id from ST_LLD where ZHTH='''+spub_zhth+''' and  ND='''+spub_nd+''' AND DH like ''%'+dhedit.text+''''

2,507

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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