oracle mybatis 分页查询
时间: 2023-08-27 22:17:06 浏览: 104
对于Oracle数据库的MyBatis分页查询,可以使用ROWNUM来实现。以下是一个示例的查询语句:
```
<select id="queryUserListForPage" parameterClass="Page" resultMap="UserInfoResult">
SELECT *
FROM (
SELECT t.*, ROWNUM AS RM
FROM (
SELECT *
FROM tb_user_info
WHERE ROWNUM <= #{max}
) t
WHERE RM > #{offset}
)
</select>
```
在这个例子中,首先我们使用ROWNUM限制了结果集的最大行数。然后,我们使用嵌套的SELECT语句将结果集按照ROWNUM进行排序,并使用RM作为别名。最后,我们在外层的SELECT语句中使用BETWEEN和#{startNum}、#{endNum}参数来实现分页功能。
请注意,这只是一个示例的查询语句,具体的实现可能会根据具体的业务需求而有所不同。另外,请确保你已经正确地配置了MyBatis和分页插件(比如PageHelper),以便在查询中正确地使用分页功能。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [mybatis+oracle实现分页查询--非常简单实用](https://blog.csdn.net/change2970955076/article/details/77427901)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [mybatis+oracle+pageHelper实现一对多连表查询结果集正确分页(父表和子表都可带查询条件)](https://blog.csdn.net/weixin_44831228/article/details/110132996)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [oracle+mybatis分页查询](https://blog.csdn.net/anythingcool/article/details/77973272)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文