1.在使用mybatisPlus分页插件的同时,使用HAVING函数会出现假列找不到的问题,因为使用插件会自动查询总条数 select count(*) from xxx having x 在拼接HAVING的条件就会找不到那个列报错,所以要在sql外层包一层就可以解决报错问题
select * from (select xx from xxx)
示例:
user表
id | name |
1 | 小明 |
2 | 小红 |
select
u.id,
u.name,
(select count(*) from user) as count
from user u
having count>1
此时,在使用mybatisPlus分页插件时,就会出现unknow count的报错。
select * from
(
select u.id,
u.name,
(select count(*) from user) as count
from user u
having count>1
) a