MyBatis操作-条件查询

0 阅读1分钟

使用的SQL语句

select * from emp where name like concat('%','张','%') and gender = 1 and entrydate between '2010-01-01' and '2021-01-01' order by update_time desc

EmpMapper接口来

@Select("select * from emp where name like concat('%','张','%') and gender = 1 and entrydate between '2010-01-01' and '2021-01-01' order by update_time desc ")
public List<Emp> list(String name, Short gender, LocalDate begin,LocalDate end);

测试

@Testjava
public void testList(){
    List<Emp> EmpList = empMapper.list("张", (short) 1, LocalDate.of(2010, 1, 1), LocalDate.of(2020, 1, 1));
    System.out.println(EmpList);
}