当前使用版本(必填,否则不予处理)
该问题是如何引起的?(确定最新版也有问题再提!!!)
分页时如果注入了动态参数在left join b on a.id=b.id and b.user_id=#{user_id} 则分页count查询时会将select * from a left join b on a.id=b.id and b.user_id=#{user_id}将笛卡尔积的关联数据也查出来了,所以count不准确
重现步骤(如果有就写完整)
报错信息
SELECT a.*, ap.picture_url, u.username, u.nickname, u.avatar, c.id cid, c.NAME cname, IF ( ag.user_id IS NULL, 0, 1 ) AS is_like FROM article a LEFT JOIN article_picture ap ON a.id = ap.article_id LEFT JOIN USER u ON a.user_id = u.id LEFT JOIN category c ON a.category_id = c.id -- LEFT JOIN article_good ag ON ag.article_id = a.id AND ag.user_id = #{这里是动态的参数,如果在这里注入动态参数,则分页结果total错乱,将这个参数写死,则分页正常} WHERE 1 = 1 AND a.STATUS = 0 AND a.user_id = 1
Comment From: ruyudeshuileling
3.4以后的版本都存在这个问题,之前的不知道
Comment From: miemieYaho
自己去想