参考:springboot 中 分页实现、SpringBoot分页插件PageHelper
目录
1. sql分页
-
语句样式: MySQL中,可用如下方法: SELECT * FROM 表名称 LIMIT ${offset},${limit}
-
适应场景: 适用于数据量较少的情况(元组百/千级)
-
原因/缺点: 全表扫描,速度会很慢 且 有的数据库结果集返回不稳定(如某次返回1,2,3,另外的一次返回2,1,3). Limit限制的是从结果集的M位置处取出N条输出,其余抛弃.
eg:
<select id="list" resultType="com.sqlb.pojo.Article">
select
<include refid="Base_Column_List"/>
from article
<where>
<if test="id != null and id != ''">and id = #{id}</if>
<if test="author != null and author != ''">and author = #{author}</if>
<if test="createTime != null and createTime != ''">and create_time = #{createTime}</if>
<if test="typeName != null and typeName != ''">and type_name = #{typeName}</if>
<if test="imageUrl != null and imageUrl != ''">and image_url = #{imageUrl}</if>
<if test="content != null and