使Mybatis-PageHelper用分頁插件,可寫自定義查詢COUNT的SQL語句,在列表查詢的id后面加上后綴_COUNT,如下:
<select id="selectLeftjoin" resultType="com.github.pagehelper.model.User"> select a.id,b.name,a.py from user a left join user b on a.id = b.id order by a.id </select> <select id="selectLeftjoin_COUNT" resultType="Long"> select count(distinct a.id) from user a left join user b on a.id = b.id </select>
詳細請參考:https://github.com/pagehelper/Mybatis-PageHelper/blob/master/wikis/zh/Changelog.md#504---2017-08-01
