时间:2021-07-01 10:21:17 帮助过:21人阅读
--查询参与了考试的学生信息 exists in select * from StudentInfo where sId in(select distinct stuid from ScoreInfo) select * from StudentInfo where exists (select * from ScoreInfo where ScoreInfo.stuId=StudentInfo.sid)View Code
2、分页
(1)提供索引
select *, ROW_NUMBER() over(order by sid desc) as rowIndex from StudentInfoView Code
(2)举例子
--分页 已知:页大小(一页显示多少条数据),页索引 -- 3,4 1,2,3,4 --1,3 1,3 (pageIndex-1)*pageSize+1 pageIndex*pageSize --2,3 4,6 --3,3 7,9 --4,3 10,12 --2,4 5,8 select * from (select *, ROW_NUMBER() over(order by sid desc) as rowIndex from StudentInfo) as t1 where rowindex between 5 and 8View Code
数据库复习总结(15)-子查询(分页)
标签:test eve distinct sel pre alt none 显示 click