使用Mybatisplus进行查询时, 遇到了需要查询最大值的情况,特此记录一下。虽然能解决问题,但不推荐使用。
在serviceImpl中编写如下代码
最大值:
this.getOne(new LambdaQueryWrapper<Test>().orderByDesc(Test::getSorlt).last("limit 1"));
最小值
this.getOne(new LambdaQueryWrapper<Test>().orderByAsc(Test::getSorlt).last("limit 1"));