实现
last()方法说明
/**
* <p>
* 手动把sql拼接到最后(有sql注入的风险,请谨慎使用)
* </p>
*
* @param limit
* @return this
*/
public Wrapper<T> last(String limit) {
sql.LAST(limit);
return this;
}
示例代码1
MyBatisPlus条件构造器实现降序排序的两种方式
List<Employee> employeeList=employeeMapper.selectList(new EntityWrapper<Employee>()
.eq("gender",1)
.like("name", "霸")
.orderBy("age")
.last("desc")
);
执行sql:
SELECT id AS id,`name`,email,gender,age FROM employee WHERE (gender = ? AND name LIKE ?) ORDER BY age desc
示例代码2
List<Employee> employeeList=employeeMapper.selectList(new EntityWrapper<Employee>()
.eq("gender",1)
.like("name", "霸")
.orderBy("age")
.last("desc limit 1,2")
);
执行sql:
SELECT id AS id,`name`,email,gender,age FROM employee WHERE (gender = ? AND name LIKE ?) ORDER BY age desc limit 1,2
效果:
标签:MyBatisPlus,name,gender,age,sql,limit,器中,last From: https://blog.51cto.com/BADAOLIUMANGQZ/6117129