当前位置:Gxlcms > 数据库问题 > 多表连接的分页sql语句:

多表连接的分页sql语句:

时间:2021-07-01 10:21:17 帮助过:2人阅读

 

           //原先

          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  页索引*页大小

多表连接的分页sql语句:

标签:

人气教程排行