DECLARE @pageindex INT;
DECLARE @pagesize INT;
SET @pageindex=2;
SET @pagesize=3;
--ROW_NUMBER具有通用性,以后就用它
SELECT * FROM
(SELECT ROW_NUMBER() OVER(ORDER BY Id) AS rownumb,* FROM T_News ) A
WHERE (NewsTitle LIKE '%国%' OR NewsContent LIKE '%国%') AND
rownumb>(@pageindex-1)*@pagesize AND rownumb<=@pageindex*@pagesize
GO
DECLARE @pageindex INT;
DECLARE @pagesize INT;
SET @pageindex=2;
SET @pagesize=3;
--ROW_NUMBER具有通用性,以后就用它
SELECT * FROM
(SELECT ROW_NUMBER() OVER(ORDER BY Id) AS rownumb,* FROM T_News WHERE NewsTitle LIKE '%国%' OR NewsContent LIKE '%国%') A
WHERE rownumb>(@pageindex-1)*@pagesize AND rownumb<=@pageindex*@pagesize
SELECT * FROM T_News WHERE Id>0 AND Id<=3
SELECT * FROM
(SELECT ROW_NUMBER() OVER(ORDER BY Id) AS rownumber, NewsTitle,NewsContent,CreateTime FROM T_News
WHERE NewsTitle LIKE '%国%' OR NewsContent LIKE '%国%') A
WHERE A.rownumber>0 AND A.rownumber<=3