日期:2014-05-18  浏览次数:20616 次

多次模糊查询有没有什么好方法?
想在一列中查找包含字符‘·’,‘#’,‘%’,‘(’,‘)’……的结果有没有什么好方法?


------解决方案--------------------
SQL code

create table test1
(strA varchar(100))

insert into test1 select 'abc·defghig' union all
select '12345%67'

select * from test1 where CHARINDEX ('·',strA)>0 or CHARINDEX ('%',strA)>0  or CHARINDEX ('(',strA)>0  or CHARINDEX (')',strA)>0

------解决方案--------------------
SQL code


create table a(b varchar(100)) 
insert into a 
select 'qeturojt'
select'123%34358' union all
select'1233435#8' union all
select'1(3%34358' union all 
select'1.3#43)8'

select * from a where b like '%.%' or b like '%#%' 
or CHARINDEX('%',b)>0 or b like '%(%' or b like '%)%'

 drop table a