sql查询文章上一篇下一篇

--- 使用字符串拼接id,title
SELECT
    *,
    before = ( SELECT TOP 1 (convert(varchar(36),ContentId)+'|'+Title) as aa FROM Cms_Content WHERE CreateDate > ( SELECT CreateDate FROM Cms_Content WHERE ContentId = 'E1E75C65-AD85-4DC5-A74A-AE0892BABA38' )and Status = 1 and IsDelete = 0  ORDER BY CreateDate ),
    after = ( SELECT TOP 1 (convert(varchar(36),ContentId)+'|'+Title) FROM Cms_Content WHERE CreateDate < ( SELECT CreateDate FROM Cms_Content WHERE ContentId = 'E1E75C65-AD85-4DC5-A74A-AE0892BABA38' )and Status = 1 and IsDelete = 0  ORDER BY CreateDate DESC )
FROM
    Cms_Content 
WHERE
    ContentId = 'E1E75C65-AD85-4DC5-A74A-AE0892BABA38' and Status = 1 and IsDelete = 0

  

posted @ 2019-09-24 14:55  86727515  阅读(750)  评论(0编辑  收藏  举报