分页查询:https://blog.csdn.net/chwenbin/article/details/79134273
对哪个表进行分页的话,将模板语句中的sys_orderdetail 更换成需要的表即可(如果自己的主键不是id换了即可),该位置也可以是
是临时表数据
如:
select * from (select *,ROW_NUMBER() over(order by id asc)row
from(
--------这坨就是临时表数据了
select
sys_user.id,username,usercode,sys_user_role.sys_role_id AS sysRoleId,sys_role.name ,sys_user.start
from
sys_user left join sys_user_role
on
sys_user.id = sys_user_role.sys_user_id left join sys_role
on
sys_user_role.sys_role_id = sys_role.id
---------
)t)t1 where t1.row between #{first} and #{last}
模板语句:
select * from (select *,ROW_NUMBER() over(order by id asc)row
from sys_orderdetail t)t1 where t1.row between 1 and 4
网友评论