简体   繁体   English

像运算符不起作用

[英]Like Operator does not work

I have the following code in SQL Server 2014 Enterprise:我在 SQL Server 2014 Enterprise 中有以下代码:

SELECT c.Id
FROM dbo.Content c 
WHERE c.Id = 8753495 AND c.Content LIKE '%Paypal%'

This code is used to know if the content has a match with the word Paypal and is returning 0 results, and for that id, I know it has in the content the word "Paypal" .此代码用于了解内容是否与单词 Paypal 匹配并返回 0 结果,对于该 ID,我知道内容中包含单词 "Paypal" 。

I've tried with different words of the content and with some words it's working and with others doesn't.我试过用不同的词来描述内容,有些词是有效的,而另一些则不行。

The database as well as the Content table both use the SQL_Latin1_General_CP1_CI_AS collation.数据库和Content表都使用SQL_Latin1_General_CP1_CI_AS归类。

Can anyone help me?谁能帮我?

EDIT: The purpose of this query is do something else, not only return the id, but I found the problem on the like operator, so I give you the part that is failing编辑:此查询的目的是做其他事情,不仅返回 id,而且我在 like 运算符上发现了问题,所以我给你失败的部分

Also tried with upper/lower but still doesn't work也试过上/下但仍然不起作用

Here is the creation script.这是创建脚本。

CREATE TABLE [dbo].[Content](
    [Id] [int] NOT NULL,
    [Content] [nvarchar](max) NULL,
 CONSTRAINT [PK_Content_1] PRIMARY KEY CLUSTERED 
(
    [Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 100) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO

Thanks for the replies.感谢您的回复。

EDIT 2: This question isn't answer by the Like operation returns no rows on nvarchar column filter if the column data start with numeric .编辑 2: 如果列数据以 numeric 开头,Like 操作不会在 nvarchar 列过滤器上返回任何行,不回答此问题。 There was a space at the end of the pattern.图案末尾有一个空格。

The problem here was a malicious client that put characters that looks similar, this way avoids verifications and could send spam这里的问题是恶意客户端放置了看起来相似的字符,这样可以避免验证并可能发送垃圾邮件

For example, the Unicode 1056 decimal (420 hexa) is a greek character similar to the Latin P (Ascii 80)例如,Unicode 1056 十进制 (420 hexa) 是一个类似于拉丁文 P (Ascii 80) 的希腊字符

在此处输入图片说明

Well, I found the error.嗯,我发现了错误。

The content was uploaded by a client (a spammer) and when look the ascii of each character, I found out that the client put the content on unicode characters that are similar.内容是由客户端(垃圾邮件发送者)上传的,当查看每个字符的 ascii 时,我发现客户端将内容放在相似的 unicode 字符上。

So "Paypal" wasn't "Paypal" like expected, here is the result of the Paypal word with the comparison with expected result:所以“Paypal”不像预期的“Paypal”,这是Paypal词与预期结果的比较结果: Unicode 结果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM