标签:
多表连接的分页sql语句:
//原先
select top 页大小 a.aid from 表1 a left join 表2 b on a.aid=b.aid where a.aid not in (select top 页索引*页大小 爱的 from
表1 a left join 表2 b on a.aid=b.aid where 条件) and 条件;
//优化后
with c as ( select rn=row_number() over(order by x.id),* from (select * from 表1 a left join 表2 b on a.aid=b.aid where 条件) x )
select * from c where rn between (页索引- 1) * 页大小 + 1 and 页索引*页大小
标签:
原文地址:http://www.cnblogs.com/1119737746chili/p/5556044.html