后端-框架-MyBatis-动态SQL-limit

后端-框架-MyBatis-动态SQL-limit

public interface UserMapper {
	public int count();
	public List<User> getUserListLimit(@Param("userName")String userName,
										@Param("userRole")Integer roleId,
										@Param("from")Integer currentPageNo,
										@Param("pageSize")Integer pageSize);
}

主要是加入limit

<select id="getUserListLimit" resultMap="getUserList">
	select user.* from smbms_user as user
	<trim prefix="WHERE" prefixOverrides="AND |OR ">
		<if test="userName != null and userName != '' ">
			and user.userName like Concat('%',#{userName},'%')
		if>
		<if test="userRole != null">
			and user.userRole=#{userRole}
		if>
	trim>
	order by creationDate DESC 
	LIMIT #{from},#{pageSize}
select>

你可能感兴趣的:(后端,框架,MyBatis)