使用分页查询(mybatis自带的)selectPage(page,wrapper)时报错

使用分页查询(mybatis自带的)selectPage(page,wrapper)时报错_第1张图片

IDEA显示语法错误,将语法扒下来:

### SQL:
SELECT * FROM (SELECT TMP_PAGE.*,ROWNUMBER() OVER() AS ROW_ID
FROM
(   SELECT  id,company_id,company_name,name,users,tags,mt,st,grade,teachmode,description,pic,create_date,change_date,create_people,change_people,audit_status,status  
FROM course_base     
WHERE (name LIKE ? AND audit_status = ?) )
AS TMP_PAGE) TMP_PAGE WHERE ROW_ID BETWEEN ? AND ?

将SQL语句放在数据库中运行,发现是ROWNUMBER()中间需要添加一个"_"

SELECT * FROM (SELECT TMP_PAGE.*,ROW_NUMBER() OVER() AS ROW_ID
FROM
(   SELECT  id,company_id,company_name,name,users,tags,mt,st,grade,teachmode,description,pic,create_date,change_date,create_people,change_people,audit_status,status  
FROM course_base     
WHERE (name LIKE '%java%' AND audit_status = '202004') )
AS TMP_PAGE) TMP_PAGE WHERE ROW_ID BETWEEN 1 AND 2

得出了结果:

使用分页查询(mybatis自带的)selectPage(page,wrapper)时报错_第2张图片

而后在mapper自定义一个sql语句,这里就不再说了

你可能感兴趣的:(intellij-idea,java,ide,数据库)