User1713851783 posted
I'm not sure I have understood your query.
If you want to filter the record that have the PageIds returned by the query
SELECT PageId FROM Pages ORDER BY PageId, Url DESC OFFSET @1 ROWS FETCH NEXT @2 ROWS ONLY
and
Url LIKE @0
you could try to modify your code as follows
commandText = @"SELECT Pages.PageId, Url, Pages.DateCreated, Title, ContentId, Content, Published FROM Pages
INNER JOIN PageContent ON Pages.PageId = PageContent.PageId WHERE Pages.PageId IN (SELECT
PageId FROM Pages ";
if(!includeArchived) {
commandText += "WHERE DateArchived IS NULL ";
}
commandText += @"ORDER BY PageId, Url DESC OFFSET @1 ROWS FETCH NEXT @2 ROWS ONLY) AND Url LIKE @0
ORDER BY Pages.DateCreated DESC";