我正在尝试编写 sql 查询来显示用户已添加书签的搜索抛出资源。我的问题是当用户键入关键字时,搜索将搜索网站上的所有资源,包括他的书签我希望能够搜索用户书签
SELECT
a.Id ,
a.summary ,
a.pageId ,
a.name ,
a.createdOn ,
a.userID ,
Total
FROM Resources AS a
LEFT JOIN Topics_Resources AS b ON a.Id = b.ResourceID
LEFT JOIN Skills_Resources AS c ON a.Id = c.ResourceID
INNER JOIN Modules AS m ON a.ModuleId = m.ModuleID
INNER JOIN ContentItems AS ci ON m.ModuleID = ci.ModuleID
INNER JOIN Tabs AS t ON t.TabID = ci.TabID
INNER JOIN TabModules AS tb ON t.TabID = tb.TabID
INNER JOIN Bookmarks ON a.Id = Bookmarks.resourceID
INNER JOIN Bookmarks AS Bookmarks_1 ON a.Id = Bookmarks_1.resourceID
INNER JOIN
(
SELECT
r.Id , COUNT(l.resourceId) Total
FROM resources r
LEFT JOIN likes l ON r.Id = l.resourceid
GROUP BY r.Id
)
l ON a.Id = l.Id
LEFT OUTER JOIN HtmlText AS h ON tb.ModuleID = h.ModuleID
WHERE (h.content LIKE '%winter%')
OR (t.description LIKE '%winter%')
OR (t.keywords LIKE '%winter%')
OR (a.summary LIKE '%winter%')
AND Bookmarks.userID = '695A8626-A28B-4308-AD9B-D5AC576B4E5A'
GROUP BY a.Id ,
a.summary ,
a.pageId ,
a.name ,
a.createdOn ,
a.userID ,
Total
ORDER BY a.createdOn DESC