1
我在數據庫中有兩個文件名(Text和Text1) Text.txt內容包含「data」。 Text1.txt內容包括「data」和「data1」。檢索最相似的內容並顯示爲SQL中的第一個結果
SQL查詢,我寫道:
SELECT [FileName], [FilePath] FROM dbo.[tb_CrawlData] cr
WHERE EXISTS (SELECT 1 FROM [tb_CrawlData] cd
WHERE cd.Content like '%data%' AND
cr.Content like '%' + cd.Content + '%'
)
GROUP BY cr.FileName, [FilePath]
ORDER BY cr.FileName
結果:
FileName FilePath
Text.txt H:\Text.txt
Text1.txt H:\New folder (2)\Text1.txt
預期結果:
如果我搜索 「數據」,我想獲得Text1.txt首先在我的第一行 ,因爲它有兩個相似的內容(「數據」和「數據1」)。 Text.txt應顯示第二行,因爲它僅包含(「數據」)。
@GurV ......太感謝你了 這正是我想要的。 –