易截截图软件、单文件、免安装、纯绿色、仅160KB

求助,SQL中通配符 - MS-SQL Server / 疑难问题

SQL code:
现有以字符串如下:字段Description 中一条记录为'RESISTOR-MELF*MF-1OHM*1%*1.5MMX3.6MM-0204'
我想从中查找关键字 Declare @Keyword
当@Keyword='1OHM'
我用如下匹配Description not like '%[*-]'+@Keyword+'[*-]%'
当@Keyword='RESISTOR-MELF*MF-1OHM*1%*1.5MMX3.6MM-0204'
我用Description not like '%'+@Keyword+'%'
我能不能将以上两个查询融合到一个语句中,求助各位大大们

我现在想到的是在Description not like '%[*-]'+@Keyword+'[*-]%'中将[*-]中加上代表空的字符,但是我不知道该怎么写,求教啊~


么懂
来点数据看看


难度好像很高

引用
么懂
来点数据看看


...

SQL code:

select *
from tbl
where (@Keyword='1OHM' and Description not like '%[*-]'+@Keyword+'[*-]%')
or (@Keyword='RESISTOR-MELF*MF-1OHM*1%*1.5MMX3.6MM-0204' and Description not like '%'+@Keyword+'%')




引用

SQL code

select *
from tbl
where (@Keyword='1OHM' and Description not like '%[*-]'+@Keyword+'[*-]%')
or (@Keyword='RESISTOR-MELF*MF-1OHM*1%*1.5MMX3.6MM-0204' and Description not like '%'+@Keyword+……

问题我自己解决了
SQL code



Code highlighting produced by Actipro Co


相关问答:

两句SQL并一句,有问题. - MS-SQL Server / 基础类

第一句:
select ht.gfdm,gfdm.gfmc,gfdm.lb ,sum(jh.htdj*jh.htsl)as je
from ht left join gfdm on ht.gfdm=gfdm.gfdm 
 join jh on ht.htbh=jh.hth 
and ht.htbh not like'del%' and ht. ......

请教SQLSERVER的两个问题 - MS-SQL Server / 疑难问题

1。怎样使xp_cmdshell能完整输出超过255个字符的字符串。
2。select 时,检索速度是与from后的 TABLE顺序有关,还是与where条件的顺序有关(TABLE数据多少 )
在系统属性设定里有个选项,可以修改单字段输出字数限制. ......

求一SQL写法 - MS-SQL Server / 基础类

id                           url                   rank     ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号