选择使用LIKE不返回值 [英] Select using LIKE not return value

查看:69
本文介绍了选择使用LIKE不返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



我有一个问题我不明白

i有此表

< pre lang =SQL> CREATE [安全].[ServiceOperations]

[ServiceOperation_ID] [ bigint ] IDENTITY 1 1
NOT NULL
[ServiceContract_ID] [ bigint ] NULL
[OperationName] [ nvarchar ](MAX) NULL
[Name_Ar] [ nvarchar ](MAX) NULL
[Name_En] [ nvarchar ](MAX) NULL


带有这些数据的


  SET   IDENTITY_INSERT  [安全性]。[ServiceOperations]  ON  

GO
INSERT [安全性]。[ServiceOperations]([ServiceOperation_ID],[ServiceContract_ID],[ OperationName],[Name_Ar],[Name_En]) VALUES 1 1 ,N ' DGIT.Business.Entities.DMS.StoredFile GetFile(Int64)',N ' جلبالملفمنخلالرقمالملف',N ' 从文件ID返回文件'
GO
INSERT [安全性]。[ServiceOperations]([ServiceOperation_ID],[ServiceContract_ID],[OperationName],[Name_Ar],[Name_En]) VALUES 2 1 ,N ' DGIT.Business.Entities.DMS.StoredFile [] GetFiles(System.Guid)',N ' < span class =code-string>جلبالملفمنخلالالرقمالمرجعي',N ' 从中返回文件文件Guid ID'
GO
INSERT [安全性]。[ServiceOperations]([ServiceOperation_ID],[ServiceContract_ID],[OperationName],[Name_Ar],[Name_En]) VALUES 3 1 ,N ' Boolean删除(Int64)',N ' حذفملفمنخلارقم الملف',N ' 按文件ID'删除文件)
GO
INSERT [安全]。 [ServiceOperations]([ServiceOperation_ID],[ServiceContract_ID],[OperationName],[Name_Ar],[Name_En]) VALUES 4 1 ,N ' Int64 CreateUpdate (DGIT.Business.Entities.DMS.StoredFile)',N ' انشاءاوتعديلملف',N ' 创建或更新文件'
GO
INSERT [安全性]。[ServiceOperations]([ServiceOperation_ID],[ServiceContract_ID],[OperationName],[Name_Ar],[Name_En]) VALUES 5 1 ,N ' Int64 GetCount(DGIT.Business.Entities.DMS.StoredFile)',N ' جلبعددالملفات',N ' 获取文件计数'
GO
INSERT [安全性]。[ServiceOperations]([ServiceOperation_ID],[ServiceContract_ID],[OperationName],[Name_Ar],[Name_En]) VALUES 6 0 ,N ' [] [] [] []',N ' ',N < span class =code-string>' '
GO
SET IDENTITY_INSERT [安全] 。[ServiceOperations] OFF





当我使用like查询记录时



  SELECT  *  FROM  安全性 .ServiceOperations  AS 所以 WHERE  OperationName  LIKE  '  DGIT.Business.Entities。 DMS.StoredFile [] GetFi les(System.Guid)' 



它没有返回数据'[]'的原因,但它使用'='运算符

解决方案

你好



问题是在like运算符中,双方括号是通配符。请参阅 http://www.w3schools.com/sql/sql_wildcards.asp [ ^ ]



根据Microsoft将通配符解释为您需要将其包含在[]中的文字。这意味着在你的情况下你应该使用[[]]而不是[]。



试试这个。它应该工作


用[[]]替换[]并且它将起作用:

 SELECT * FROM ServiceOperations AS so WHERE OperationName LIKE 'DGIT.Business.Entities.DMS.StoredFile [[]] GetFiles(System.Guid)'


试试这个:

  SELECT  
*
FROM 安全性 .ServiceOperations AS 所以
WHERE
OperationName LIKE REPLACE(REPLACE(' DGIT。 Business.Entities.DMS.StoredFile [] GetFiles(System.Guid)'' ['' [['),' ]'' ]]'


Dears,

I have an issue i don't understand
i have this table

CREATE TABLE [Security].[ServiceOperations]
    (
      [ServiceOperation_ID] [bigint] IDENTITY(1, 1)
                                     NOT NULL ,
      [ServiceContract_ID] [bigint] NULL ,
      [OperationName] [nvarchar](MAX) NULL ,
      [Name_Ar] [nvarchar](MAX) NULL ,
      [Name_En] [nvarchar](MAX) NULL
    )


with these data

SET IDENTITY_INSERT [Security].[ServiceOperations] ON 

GO
INSERT [Security].[ServiceOperations] ([ServiceOperation_ID], [ServiceContract_ID], [OperationName], [Name_Ar], [Name_En]) VALUES (1, 1, N'DGIT.Business.Entities.DMS.StoredFile GetFile(Int64)', N'جلب الملف من خلال رقم الملف', N'Return file from file id')
GO
INSERT [Security].[ServiceOperations] ([ServiceOperation_ID], [ServiceContract_ID], [OperationName], [Name_Ar], [Name_En]) VALUES (2, 1, N'DGIT.Business.Entities.DMS.StoredFile[] GetFiles(System.Guid)', N'جلب الملف من خلال الرقم المرجعي', N'Return file from file Guid ID')
GO
INSERT [Security].[ServiceOperations] ([ServiceOperation_ID], [ServiceContract_ID], [OperationName], [Name_Ar], [Name_En]) VALUES (3, 1, N'Boolean Delete(Int64)', N'حذف ملف من خلا رقم الملف', N'Delete file by file ID')
GO
INSERT [Security].[ServiceOperations] ([ServiceOperation_ID], [ServiceContract_ID], [OperationName], [Name_Ar], [Name_En]) VALUES (4, 1, N'Int64 CreateUpdate(DGIT.Business.Entities.DMS.StoredFile)', N'انشاء او تعديل ملف ', N'Create or Update file')
GO
INSERT [Security].[ServiceOperations] ([ServiceOperation_ID], [ServiceContract_ID], [OperationName], [Name_Ar], [Name_En]) VALUES (5, 1, N'Int64 GetCount(DGIT.Business.Entities.DMS.StoredFile)', N'جلب عدد الملفات', N'Get files count')
GO
INSERT [Security].[ServiceOperations] ([ServiceOperation_ID], [ServiceContract_ID], [OperationName], [Name_Ar], [Name_En]) VALUES (6, 0, N'[][][][]', N'', N'')
GO
SET IDENTITY_INSERT [Security].[ServiceOperations] OFF



when i query for a record using like

SELECT * FROM Security.ServiceOperations AS so WHERE OperationName LIKE 'DGIT.Business.Entities.DMS.StoredFile[] GetFiles(System.Guid)'


its not returning data cause of the '[]' but its returning using '=' operator

解决方案

Hi

The problem is that in the like operator the double square brackets are wildcards. See http://www.w3schools.com/sql/sql_wildcards.asp[^]

According to Microsoft to interpret a wildcard character as a literal you need to enclose it inside []. This would mean that in your case you should use [[]] instead of [].

Try this. It should work


replace [] with [[]] and it will work:

SELECT * FROM ServiceOperations AS so WHERE OperationName LIKE 'DGIT.Business.Entities.DMS.StoredFile[[]] GetFiles(System.Guid)'


Try this:

SELECT 
    * 
FROM Security.ServiceOperations AS so 
WHERE 
     OperationName LIKE REPLACE(REPLACE('DGIT.Business.Entities.DMS.StoredFile[] GetFiles(System.Guid)', '[', '[['),']',']]')


这篇关于选择使用LIKE不返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆