赞
踩
先看Mybatis-Plus官网中对这两个关键字用法的介绍
数据库文件:
链接:https://pan.baidu.com/s/1KzY32Jq0srDQU9m-a-YtBQ?pwd=rsdg
提取码:rsdg
表数据:
sql语句为:select * FROM student where age='23' or school_id='300'
最直接的方法:
List<Student> students = studentMapper
.selectList(Wrappers.lambdaQuery(Student.class)
.eq(Student::getAge, "23")
.or()
.eq(Student::getSchoolId,300));
也可以用下面的方法
用mybatis-plus则为:
List<Student> students = studentMapper.selectList(Wrappers.lambdaQuery(Student.class) .eq(Student::getAge, "23") .or(s -> s.eq(Student::getSchoolId, 300)));
sql语句:select * FROM student where age='25' or `name` LIKE '张%'
用mybatis-plus最直接的方法
List<Student> students = studentMapper .selectList(Wrappers.lambdaQuery(Student.class) .eq(Student::getAge, "25") .or() .likeRight(Student::getName, "张"));
也可以用以下方法
List<Student> students = studentMapper .selectList(Wrappers.lambdaQuery(Student.class) .eq(Student::getAge, "25") .or(s->s.likeRight(Student::getName,"张")));
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。