各路牛哥帮忙

wanglaibing 2009-08-10 01:25:19

s:='%';
query1.close;
query1.SQL.clear;
query1.SQL.Add('update pub_expert_data set is_flag=:_is_flag where :_expertcode like '+'''s'''+'+ expert_code +'+'''s''');
add_ado.Parameters.ParamByName('_expertcode').Value:='2,1,3,4';(expert_coder的值是‘2’或‘1’或‘3’或‘4’)
add_ado.Parameters.ParamByName('_is_flag').Value:='必选';
query1.execsql;

为何更新不了?‘%’写在‘update’句里应该怎么写?
...全文
66 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wanglaibing 2009-08-10
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 sunshinegyy 的回复:]
是要判断包含expert_code的串么?直接:_expertcode like ''%'+ expert_code +'%''不行么
[/Quote]

能不能写清楚点,我用你这个编译不过去啊?
wanglaibing 2009-08-10
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 yct0605 的回复:]
引用 2 楼 sunshinegyy 的回复:
是要判断包含expert_code的串么?直接:_expertcode like ''%'+ expert_code +'%''不行么

你写的语句就有问题啊,正确的带参数写法就是2楼的,你参照一下吧,
add_ado.Parameters.ParamByName('_expertcode').Value:='2,1,3,4';这个语法根本就不正确,参数“_expertcode”只能对应一个值,你怎么对应4个啊?
[/Quote]

“_expertcode"这个参数可以写入“2,1,4,5”而expert_code 只是其中的一个值,所以才会查的出来数据,
wanglaibing 2009-08-10
  • 打赏
  • 举报
回复
我把语句放在SQL SERVER中存储过程是对的
sql server:
update pub_expert_data set is_flag='1' where @same_specl like '%'+expert_code+'%'

可现在要换成access,它不支持存储过程,所以这个后面的判断放在delphi中我不知怎么写了
yct0605 2009-08-10
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 sunshinegyy 的回复:]
是要判断包含expert_code的串么?直接:_expertcode like ''%'+ expert_code +'%''不行么
[/Quote]
你写的语句就有问题啊,正确的带参数写法就是2楼的,你参照一下吧,
add_ado.Parameters.ParamByName('_expertcode').Value:='2,1,3,4';这个语法根本就不正确,参数“_expertcode”只能对应一个值,你怎么对应4个啊?
sunshinegyy 2009-08-10
  • 打赏
  • 举报
回复
是要判断包含expert_code的串么?直接:_expertcode like ''%'+ expert_code +'%''不行么
bdmh 2009-08-10
  • 打赏
  • 举报
回复
select * from table where name like '%军%'

再有你where 后面的参数是什么东西,where后应该跟字段名去设置条件,你怎么会给这个参数赋值为'2,1,3,4'呢

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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