模糊查询的关键字
2008-02-29 12:49
239 查看
模糊查询的关键字例:
ABC =====>%A%B%C%
create function fun_SearchKey(@temp varchar(50))
------模糊查询的关键字----
RETURNS VARCHAR(100)
AS
BEGIN
DECLARE @temp1 varchar(50),@temp2 varchar(50),@i int,@x int
set @i=len(@temp)
set @x=1
while(@x<=@i)
begin
set @temp1=substring(@temp,0,@x)
set @temp2=substring(@temp,@x,@i)
set @temp=@temp1+'%'+@temp2
set @x=@x+2
set @i=@i+1
end
set @temp=@temp+'%'
return @temp
END
---另一种查询方式---
select * from Customers where PATINDEX('%[ab]c%',CompanyName )<>0
ABC =====>%A%B%C%
create function fun_SearchKey(@temp varchar(50))
------模糊查询的关键字----
RETURNS VARCHAR(100)
AS
BEGIN
DECLARE @temp1 varchar(50),@temp2 varchar(50),@i int,@x int
set @i=len(@temp)
set @x=1
while(@x<=@i)
begin
set @temp1=substring(@temp,0,@x)
set @temp2=substring(@temp,@x,@i)
set @temp=@temp1+'%'+@temp2
set @x=@x+2
set @i=@i+1
end
set @temp=@temp+'%'
return @temp
END
---另一种查询方式---
select * from Customers where PATINDEX('%[ab]c%',CompanyName )<>0
相关文章推荐
- MySQL单表多关键字模糊查询的实现方法
- jq.ajax+php+mysql实现关键字模糊查询
- sql模糊查询查询多个关键字
- asp.net关键字模糊查询(类似于各大网站搜索功能)
- 查询数据,模糊查询,通配符,比较运算符,distinct,limit关键字
- lucene模糊查询 精确查询 包含关键字 不包含关键字 包含全部关键字 范围查询 模糊查询 通配符查询 lucene各种查询实现示例
- 关于Sql语句中的模糊查询like关键字详解
- java模糊关键字查询
- oracle Like模糊查询与带有关键字Reverse的索引应用
- mysql多关键字多字段模糊查询
- mysql多关键字多字段模糊查询
- SQL多关键字模糊查询
- 怎样能让模糊查询后得到的结果中关键字带颜色?
- SQL Server数据库--》top关键字,order by排序,distinct去除重复记录,sql聚合函数,模糊查询,通配符,空值处理。。。。
- MySQL单表多关键字模糊查询的实现
- ajax实现模糊查询(关键字描红)
- spring data jpa中@Query中的模糊查询<like关键字>
- oracle 用更高效的方法代替 LIKE 关键字的模糊查询
- SQL 多字段模糊匹配关键字查询
- 模糊查询关键字高亮显示