1.or 查询
简单or查询,拼装条件用or()方法连接
// mybatis-plus
List<Student> list = studentService.list(
new QueryWrapper<Student>()
.eq("sex", "男")
.or()
.eq("name", "张三")
);
//对应sql
select * from student where ( sex = ? or name= ? )
2.and()和or()一起使用
查询条件中出现(A or B)and (C or D)情况查询:
// mybatis-plus
List<Student> list = studentService.list(
new QueryWrapper<Student>()
.eq("name", "张三")
.or(qw->qw.eq("sex", "男").eq("age",24))
//对应sql
select * from student where ( name = ? or ( ( sex = ? and age = ? ) ) )
查询条件中出现(A and B) or (C and D)情况查询: