Old SQL:
SELECT
[FileName], [FilePath]
FROM
dbo.[tb_CrawlData] cr
WHERE
cr.Content LIKE '%' + (SELECT content
FROM [tb_CrawlData]
WHERE Content LIKE '%test1%') + '%'
GROUP BY
cr.FileName, [FilePath]
ORDER BY
cr.FileName
Old C# SQL query:
Sqlquery = "SELECT [FileName], [FilePath]"
+ " FROM [tb_CrawlData] cr "
+ " WHERE cr.Content like '%' + (" + Sqlquery.Substring(Sqlquery.IndexOf(" SELECT") + 1) + ") + '%' ";
Sqlquery += " GROUP BY cr.FileName,[FilePath]"
+ " ORDER BY cr.FileName ";
New 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
count(*) desc, cr.FileName
New C# SQL query:
The new sql, I am not so sure how to modify for c#.