select * from attendanceform LIMIT "+pageSize+" where id not in (select id from attendanceform LIMIT "+pageSize*(pageNow-1)+")
用的是mysql
报错如下
javax.servlet.ServletException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where id not in (select id from attendanceform LIMIT 3)' at line 1
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:916)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:845)
org.apache.jsp.personnel.attendanceform_jsp._jspService(attendanceform_jsp.java:334)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
3 个解决方案
#1
试试这样:
select * from attendanceform where id not in (select id from attendanceform LIMIT "+pageSize*(pageNow-1)+") LIMIT "+pageSize+"
#2
select * from attendanceform where id not in (select id from attendanceform LIMIT "+pageSize*(pageNow-1)+" LIMIT "+pageSize+") 这样更好点
#3
子查询里头不能用limit
#1
试试这样:
select * from attendanceform where id not in (select id from attendanceform LIMIT "+pageSize*(pageNow-1)+") LIMIT "+pageSize+"
#2
select * from attendanceform where id not in (select id from attendanceform LIMIT "+pageSize*(pageNow-1)+" LIMIT "+pageSize+") 这样更好点
#3
子查询里头不能用limit