您的位置:首页 > 数据库 > Oracle

oracle mysql 的mybatis 逆向工程中的分页查询的写法

2016-12-01 09:47 417 查看
mysql 分页在mybatis 中的实现
<select id="selectByExampleWithPage" resultMap="BaseResultMap" parameterType="map" >
select
<if test="example.distinct" >
distinct
</if>

4000
<include refid="Base_Column_List" />
from tb_item
<if test="example.join != null" >
${example.join}
</if>
<if test="_parameter != null" >
<include refid="Example_Where_Clause_Page" />
</if>
<if test="example.orderByClause != null" >
order by ${example.orderByClause}
</if>
limit ${startPage},${endPage}
</select>

oracle  中分页查询在mybatis 中的实现

<select id="selectByExampleWithPage" resultMap="BaseResultMap" parameterType="map" >
select * from (select g.*,rownum rn from (select
<if test="example.distinct" >
distinct
</if>
<include refid="Base_Column_List" />
from tb_content
<if test="example.join != null" >
${example.join}
</if>
<if test="_parameter != null" >
<include refid="Example_Where_Clause_Page" />
</if>
<if test="example.orderByClause != null" >
order by ${example.orderByClause}
</if>
) g where rownum < ${endPage} ) where rn >= ${startPage}
</select>

欢迎批评和指正,觉得还行请点赞,有异议欢迎留言讨论
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: