请问存储过程中模糊查询如何写??

cws123 2003-12-26 10:42:22
想做一个带参数的模糊查询,但是存储过程中看到的一般是 字段=@参数!
现在想有模糊的该如何???
...全文
41 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
cws123 2003-12-26
  • 打赏
  • 举报
回复
现在是这样的:
一个组合的查询,在asp中我这样写
sql="select id,biaoti,type,date1,link from xinwen where id<>''"
if biaoti<>"" then sql=sql+"and biaoti like '%"&biaoti&"%'"
if lanmu<>"" then sql=sql+"and type='"&lanmu&"'"
sql=sql+"order by id desc"
rs.open sql,conn,3,2
现在想在sql server中的存储过程该如何?因为有参数,所以不知!¬
reaperwu 2003-12-26
  • 打赏
  • 举报
回复
select * from table where aa like '%aa' --查询以aa结尾
select * from table where aa like 'aa%' --查询以aa开头
select * from table where aa like '%aa%' --查询aa在任意位置
yeno 2003-12-26
  • 打赏
  • 举报
回复
跟ASP中SQL语句一样的
aa=... 'aa为某变量
sql="select * from table where aa like '%"&aa&"%' "
my0707 2003-12-26
  • 打赏
  • 举报
回复
字段 like %@参数
chenxingbai 2003-12-26
  • 打赏
  • 举报
回复
select @iRowCount = count(id) from picpath where classname like '%'+@classname+'%'----取得图片数
看看这个如何

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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