Originally posted by Spacecadet
View Post

select x.linkID, x.html, x.url, x.title, x.description, x.contactEmail, x.reciprocalLinkUrl, x.status, x.lastChecked, x.missingCount, x.pageRank, x.hits, x.lastHit, x.rating, x.votes, x.averageRating, x.commentCount, x.created, x.updated
from
(Select linkID, html, url, title, description, contactEmail, reciprocalLinkUrl, status, lastChecked, missingCount, pageRank, hits, lastHit, rating, votes, averageRating, commentCount, created, updated,
substr(' ' || l.description || ' ' || l.title || ' ',seq,
CharIndex(' ' , ' ' || l.description || ' ' || l.title || ' ' , seq) - seq) as words
from SEQUENCE
inner join vwVisibleLinks l
where
seq <= length(' ' || l.description || ' ' || l.title || ' ') and
substr(' ' || l.description || ' ' || l.title || ' ', seq - 1, 1) = ' ' and
CharIndex(' ' , ' ' || l.description || ' ' || l.title || ' ' , seq) - seq > 0) as x
inner join
(Select substr(@searchTerm,seq,
CharIndex(' ' , @searchTerm , seq) - seq) as keywords
from SEQUENCE
where
seq <= length(@searchTerm) and
substr(@searchTerm, seq - 1, 1) = ' ' and
CharIndex(' ' ,@searchTerm, seq) - seq > 0) as y
on x.words like y.keywords
inner join linkCategories lc
on lc.linkID = x.linkID
inner join categories c
on lc.categoryID = c.categoryID
where c.lft between (select lft from categories where categoryID = @categoryID) and (select rgt from categories where categoryID = @categoryID)
group by x.linkID, x.html, x.url, x.title, x.description, x.contactEmail, x.reciprocalLinkUrl, x.status, x.lastChecked, x.missingCount, x.pageRank, x.hits, x.lastHit, x.rating, x.votes, x.averageRating, x.commentCount, x.created, x.updated
order by count(x.linkid) desc


select x.linkID, x.html, x.url, x.title, x.description, x.contactEmail, x.reciprocalLinkUrl, x.status, x.lastChecked, x.missingCount, x.pageRank, x.hits, x.lastHit, x.rating, x.votes, x.averageRating, x.commentCount, x.created, x.updated
from
(Select linkID, html, url, title, description, contactEmail, reciprocalLinkUrl, status, lastChecked, missingCount, pageRank, hits, lastHit, rating, votes, averageRating, commentCount, created, updated,
substr(' ' || l.description || ' ' || l.title || ' ',seq,
CharIndex(' ' , ' ' || l.description || ' ' || l.title || ' ' , seq) - seq) as words
from SEQUENCE
inner join vwVisibleLinks l
where
seq <= length(' ' || l.description || ' ' || l.title || ' ') and
substr(' ' || l.description || ' ' || l.title || ' ', seq - 1, 1) = ' ' and
CharIndex(' ' , ' ' || l.description || ' ' || l.title || ' ' , seq) - seq > 0) as x
inner join
(Select substr(@searchTerm,seq,
CharIndex(' ' , @searchTerm , seq) - seq) as keywords
from SEQUENCE
where
seq <= length(@searchTerm) and
substr(@searchTerm, seq - 1, 1) = ' ' and
CharIndex(' ' ,@searchTerm, seq) - seq > 0) as y
on x.words like y.keywords
inner join linkCategories lc
on lc.linkID = x.linkID
inner join categories c
on lc.categoryID = c.categoryID
where c.lft between (select lft from categories where categoryID = @categoryID) and (select rgt from categories where categoryID = @categoryID)
group by x.linkID, x.html, x.url, x.title, x.description, x.contactEmail, x.reciprocalLinkUrl, x.status, x.lastChecked, x.missingCount, x.pageRank, x.hits, x.lastHit, x.rating, x.votes, x.averageRating, x.commentCount, x.created, x.updated
order by count(x.linkid) desc


Leave a comment: