mybatis-plus返回查询总记录数
mp框架提供了selectCount方法,来查询总记录数;
需求:查找薪水大于3500 名字里有“小”的 员工的个数
sql实现:select count(*) from t_employee where salary>3500 and name like '%小%'
代码实现:
@Test public void selectCountByQueryWrapper11(){ QueryWrapper<Employee> queryWrapper=new QueryWrapper(); // QueryWrapper<Employee> queryWrapper2=Wrappers.<Employee>query(); queryWrapper.gt("salary",3500).like("name","小"); Integer count = employeeMapper.selectCount(queryWrapper); System.out.println(count); }
------------------------------------------------------------------------------------------------------------------------------
作者: java1234_小锋
出处:https://www.cnblogs.com/java688/p/13672061.html
版权:本站使用「CC BY 4.0」创作共享协议,转载请在文章明显位置注明作者及出处。
------------------------------------------------------------------------------------------------------------------------------