我在 Microsoft SQL Server 数据库表中有几百万条记录。搜索[Column] LIKE '%test%'
太慢了。因此,我使用全文搜索。
CONTAINS
经过大量尝试和FREETEXT
...后,我的查询如下所示
SELECT [SearchText] FROM [Service].[CatalogArticleCache] AS t
INNER JOIN CONTAINSTABLE([Service].[CatalogArticleCache], [SearchText], '"*426*"') AS s1 ON t.ArticleId = s1.[KEY]
INNER JOIN CONTAINSTABLE([Service].[CatalogArticleCache], [SearchText], '"*211*"') AS s2 ON t.ArticleId = s2.[KEY]
INNER JOIN CONTAINSTABLE([Service].[CatalogArticleCache], [SearchText], '"*Geschweisst*"') AS s3 ON t.ArticleId = s3.[KEY]
INNER JOIN CONTAINSTABLE([Service].[CatalogArticleCache], [SearchText], '"*rohr*"') AS s4 ON t.ArticleId = s4.[KEY]
--INNER JOIN CONTAINSTABLE([Service].[CatalogArticleCache], [SearchText], '"*bogen*"') AS s5 ON t.ArticleId = s5.[KEY]
ORDER BY [SearchText]
该查询返回几条记录,例如...
426 211357 .Geschweisste Rohrbogen 2d90
426 211682 .Geschweisste Leitungsrohre ungegl.
426 211990 .Geschweisste Rohrbogen D + 100
...
一旦我包含我的 SQL 查询的倒数第二行,我希望中间的结果会消失。不幸的是,查询没有返回一行。
为什么会这样以及如何解决?