我需要匹配字符串esacping单引号。我的查询是这样的:
select Distinct(a.item)
from [dbo].[Subscribtions] a
where a.Item like 'Catch Fry''s Low Impact''但它正在抛出错误
字符串“Catch Fry's Low Impact”之后的未闭合引号。
我不能使用like pattern matching%,有多个这样的字符串。由于某些数据原因,我只能使用=。
谢谢
发布于 2019-02-03 09:19:26
查找您的查询
select Distinct(a.item)
from [dbo].[Subscribtions] a
where a.Item like 'Catch Fry''s Low Impact''在'的最后一个部分有一个额外的'Catch Fry''s Low Impact'',在Distinct(a.item)中也不需要括号。
因为您是在寻找'Catch Fry''s Low Impact',所以
select Distinct a.item
from [dbo].[Subscribtions] a
where a.Item like 'Catch Fry''s Low Impact';将与
select Distinct a.item
from [dbo].[Subscribtions] a
where a.Item = 'Catch Fry''s Low Impact';所以,我认为你只是在寻找
select Distinct a.item
from [dbo].[Subscribtions] a
where a.Item = 'Catch Fry''s Low Impact';使用LIKE运算符是没有好处的,除非你是做外卡匹配。
https://stackoverflow.com/questions/54501150
复制相似问题