select * from A
where [Name] LIKE '%'+@pName+'%'
和
where @pName LIKE '%'+[Name]+'%'
有什么区别吗?
个人一直觉得是一样的 糊涂中……
盼答案
where [Name] LIKE '%'+@pName+'%'
和
where @pName LIKE '%'+[Name]+'%'
有什么区别吗?
个人一直觉得是一样的 糊涂中……
盼答案
select * from a where charindex(@pName,[Name])
这两没有区别
select * from a where charindex(@pName,[Name]) >0
这两没有区别
[ ] 指定范围 ([a-f]) 或集合 ([abcdef]) 中的任何单个字符。 WHERE au_lname LIKE '[C-P]arsen' 将查找以arsen 结尾且以介于 C 与 P 之间的任何单个字符开始的作者姓氏,例如,Carsen、Larsen、Karsen 等。
一个对@pName 进行模糊查询
select * from A where [Name] LIKE '%'+@pName+'%' --@pname包含name
select * from A where @pName LIKE '%'+[Name]+'%' 如同A到B,B到A.是两个不同的方向.
也就是你所说的两个不同的功能
(
[name] varchar(20)
)
delete from Inventory2
insert into Inventory2
select 'AADDDTTT' union all
select 'AADDDFFF' union all
select 'AADD' union all
select 'AADEFFD' declare @pName varchar(20)
set @pName = 'AADDDFFF'
select * from Inventory2
where [Name] LIKE '%'+@pName+'%' name
--------------------
AADDDFFF(1 行受影响)select * from Inventory2
where @pName LIKE '%'+[Name]+'%'
name
--------------------
AADDDFFF
AADD(2 行受影响)
ABC
B'B' LIKE '%ABC%' 不成立
'ABC' LIKE '%B%' 成立
这个么区别。 不过你前面那个LIKE是有区别的。