多表连接的分页sql语句:


多表连接的分页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  页索引*页大小


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM