mysql-limit offset分页

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ZHOU_VIP/article/details/88342550
//每页显示多少条数据
String batchVal = request.getParameter("numPerpage");
//页码
String offsetVal = request.getParameter("page");
batchVal = (batchVal == null || batchVal.trim().equals("")) ? "10" : batchVal.trim();
offsetVal = (offsetVal == null || offsetVal.trim().equals("")) ? "1" : offsetVal.trim();
DoorGuardPersonQry cond = new DoorGuardPersonQry();
cond.setBatch(Integer.parseInt(batchVal));
cond.setOffset((Integer.parseInt(offsetVal)-1)*(Integer.parseInt(batchVal)));

<select id="queryDoorGuardPerson" resultMap="BaseResultMap" >
	 SELECT          PERSONID,
			 NAME,
			 IDCARD, 
			 SEX,
			 AGE,
			 JOB,
			 DEPARTMENT,
			 BIRTHDAY,
			 ADDR,
			 TELEPHONE,
			 EMAIL,
			 EDU,
			 FLAG,
			 PHOTO,
			 AREAID,
			 PROJECTID,
			 REMARK  
	   FROM t_doorguard_person
	  WHERE 1 = 1 
	  <if test='p.personid != null and p.personid != "" '>
		 AND PERSONID = #{p.personid, jdbcType=VARCHAR} 
	  </if>
	  <if test='p.name != null and p.name != "" '>
		 AND NAME like CONCAT('%',#{p.name, jdbcType=VARCHAR},'%')
	  </if>
	  <if test='p.flag != null and p.flag != ""'>
		 AND FLAG = #{p.flag, jdbcType=VARCHAR} 
	  </if>
	  <if test='p.idcard != null and p.idcard != "" '>
		 AND IDCARD = #{p.idcard, jdbcType=VARCHAR} 
	  </if>
	  <if test='p.department != null and p.department != "" '>
		 AND DEPARTMENT like CONCAT('%',#{p.department, jdbcType=VARCHAR},'%')
	  </if>
	  ORDER BY PERSONID ASC 
	  LIMIT #{p.batch, jdbcType=INTEGER} OFFSET #{p.offset, jdbcType=INTEGER} 
</select>

https://blog.csdn.net/czh500/article/details/86270424

https://blog.csdn.net/tigerhu256/article/details/78902791

猜你喜欢

转载自blog.csdn.net/ZHOU_VIP/article/details/88342550