这是我的sp代码。我想从此sp的结果中选择下一个不同的6行。我怎样才能做到这一点?
SELECT N.NewsId,
N.HeadCaption,
(SELECT Name FROM NewsCategory
WHERE NewsCategoryId = N.HeadLineCategoryId) Category,
N.PicUrl,
N.Creation,
SUBSTRING((fnStripTags(N.Description)),1,75) AS ShortDescription
FROM News N
INNER JOIN
(SELECT HeadlineCategoryID, MAX(NewsID) max_id
FROM News
GROUP BY HeadlineCategoryID) N_
ON N.HeadlineCategoryID = N_.HeadlineCategoryID AND
N.NewsID = N_.max_id
ORDER BY N.ViewIndex DESC
LIMIT 6;
最佳答案
好的,好的,就像这样
SELECT N.NewsId,
N.HeadCaption,
(SELECT Name FROM NewsCategory
WHERE NewsCategoryId = N.HeadLineCategoryId) Category,
N.PicUrl,
N.Creation,
SUBSTRING((fnStripTags(N.Description)),1,75) AS ShortDescription
FROM News N
INNER JOIN
(SELECT HeadlineCategoryID, MAX(NewsID) max_id
FROM News
GROUP BY HeadlineCategoryID) N_
ON N.HeadlineCategoryID = N_.HeadlineCategoryID AND
N.NewsID = N_.max_id
ORDER BY N.ViewIndex DESC
LIMIT 6 limit 6;
在代码的末尾,使用“限制6”,您将从表/源中获取接下来的6行