sql server like 子句

发布于 2024-11-01 18:00:33 字数 242 浏览 0 评论 0原文

大家好,我在 SQL Server 表中有一个列是 nvarchar(max)。我用以下命令查询表:

从 CrossArticle_Article 中选择 *,其中摘要如“%PHILADELPHIA-BASED GUITARIST AND Composer Tim%”

如果我在 like 子句中输入 5 个单词,我会得到一个结果,如果我添加更多单词,即使记录存在,我也不会得到任何结果。备案有什么限制吗?

Hey guys, I have a column in an sql server table that is nvarchar(max). I query the table with:


select * from CrossArticle_Article where Summary like '%PHILADELPHIA-BASED GUITARIST AND composer Tim%'

If I enter 5 words in the like clause, I get a result, if I add more words, I dont get any results, even if the record exists. Is there any limitation for the records?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽你眉间 2024-11-08 18:00:33

没有限制。我怀疑 LIKE 子句行为正常,但您的数据是导致您未获得预期结果的原因。

您能否发布一些数据来帮助说明您在结果集中期望的记录?

declare @foo table (title Nvarchar(MAX))
INSERT INTO @foo (title) 
values ('South PHILADELPHIA-BASED GUITARIST AND composer Tim X'),
('North PHILADELPHIA-BASED GUITARIST AND composer Timofei'),
('In West-PHILADELPHIA-BASED GUITARIST AND composer Timothy Born and raised'),
('PHILADELPHIA-BASED GUITARIST AND composer Timmy Smith'),
('<p>PHILADELPHIA-BASED GUITARIST AND composer Tim Motzer finds infinite joy in diversity. His output as a leader and sideman crisscrosses multiple musical universes, including jazz, fusion, prog, hip-hop, soul, electronica, and the avantgarde.')

-- results in 5, as expected
select count(*) from @foo 
where title like '%PHILADELPHIA-BASED GUITARIST AND composer Tim%' 

-- results in 1, as expected
select count(*) from @foo 
where title like '%PHILADELPHIA-BASED GUITARIST AND composer Timmy S%' 

There's no limitation. I suspect the LIKE clause is behaving properly, but your data is the cause of you not getting the results you're expecting.

Can you post some data to help illustrate those records that you expect in your resultset?

declare @foo table (title Nvarchar(MAX))
INSERT INTO @foo (title) 
values ('South PHILADELPHIA-BASED GUITARIST AND composer Tim X'),
('North PHILADELPHIA-BASED GUITARIST AND composer Timofei'),
('In West-PHILADELPHIA-BASED GUITARIST AND composer Timothy Born and raised'),
('PHILADELPHIA-BASED GUITARIST AND composer Timmy Smith'),
('<p>PHILADELPHIA-BASED GUITARIST AND composer Tim Motzer finds infinite joy in diversity. His output as a leader and sideman crisscrosses multiple musical universes, including jazz, fusion, prog, hip-hop, soul, electronica, and the avantgarde.')

-- results in 5, as expected
select count(*) from @foo 
where title like '%PHILADELPHIA-BASED GUITARIST AND composer Tim%' 

-- results in 1, as expected
select count(*) from @foo 
where title like '%PHILADELPHIA-BASED GUITARIST AND composer Timmy S%' 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文