MyBatisPlus条件构造器带条件查询selectList使用

欧阳小白 24天前 ⋅ 23 阅读
/***
  *条件构造器 查询操作SelectList
  */
 @Test
 public void testEntitymapperSelectList() {
  //查询数据库,性别为男(1),并且名字中带有霸的记录或者email中带有123的记录。
  List<Employee> employeeList=employeeMapper.selectList(new EntityWrapper<Employee>()
    .eq("gender",1)
    .like("name", "霸")
    //.or()//SELECT id AS id,`name`,email,gender,age FROM employee WHERE (gender = ? AND name LIKE ? OR email LIKE ?)
    .orNew()//SELECT id AS id,`name`,email,gender,age FROM employee WHERE (gender = ? AND name LIKE ?) OR (email LIKE ?)
    .like("email", "123")
    );
  System.out.println("*******************"+employeeList);
  for (Employee employee : employeeList) {
   System.out.println(employee.getName());
  }
 }

全部评论: 0

    我有话说:

    咨询问题

    点击这里给我发消息

    淘宝咨询

    博主承接代做业务

    真·送云服务器

    咨询博主