SQL语句大全

分页SQL语句整理

分页SQL语句01:

pageSize:表示每一页要取多少条。如10条

pageIndex:表示页码,第几页。

SELECT  TOP pageSize * FROM (SELECT ROW_NUMBER() over(order by CID desc) as rows, CID,C_Pic,C_Name,C_Price,C_Description,C_Category,C_Author,C_Lecturer,C_Label,C_URL,UI.UserName,CC.Cc_Name,C_Recommend,C_Content FROM a_CourseList CL LEFT JOIN a_UserInfo UI ON UI.UID = CL.C_Lecturer LEFT JOIN a_CourseCategory CC ON CC.CcId=CL.C_Category WHERE CC.Cc_Author = 1 AND C_State=1 AND C_IsDel=0 AND C_Author=16) AS T where T.rows> (pageindex-1) * pageSize

 

 

left joio

select F.FbId,F.Context, U.HeadPic,U.UserName,D.D_Name,P.P_Name from a_Feedback as F
left join a_UserInfo as U on U.UID=F.UId
left join a_Department as D on D.Uid=U.UID
left join a_Position as P on P.Uid=D.Uid where F.UId=17

 

上一篇:SQL优化


下一篇:linux – .so文件中的链接器脚本? (libc.so)是吗?