Here is my sp codes. I want to select next different 6 rows from result of this sp. How can I do that?
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;
Okay, Okay, just like this
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;
at the end of code, with "limit 6" you get the next 6 rows from table/source
尝试使用SELECT DISTINCT而不是SELECT
Use the LIMIT function
The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must both be nonnegative integer constants, With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.