错误的语法,这样子会得到where type = 2 and ssjh = 3 or ssjh = 4,只要ssjh或type其中一个满足就会触发
List<CuringTypeInfo> curingTypeInfoList = curingTypeInfoService.list(
new LambdaQueryWrapper<CuringTypeInfo>().eq(CuringTypeInfo::getType, 2).eq(CuringTypeInfo::getSsjh, 3).or().eq(CuringTypeInfo::getSsjh, 4));
select id, type, con_type, con_type_note, sort , state, create_time, update_time, ssjh, create_by , update_by, remark, del_flag from t_run_curing_type_info where type = 2 and ssjh = 3 or ssjh = 4
正确的语法,where type = 2 and (ssjh = 3 or ssjh = 4) 在type满足条件的前提下,ssjh等于3或等于4即可触发
List<CuringTypeInfo> curingTypeInfoList = curingTypeInfoService.list(
new LambdaQueryWrapper<CuringTypeInfo>()
.eq(CuringTypeInfo::getType, 2)
.and(wrapper ->
wrapper.eq(CuringTypeInfo::getSsjh, 3)
.or()
.eq(CuringTypeInfo::getSsjh, 4)
)
);
select id, type, con_type, con_type_note, sort , state, create_time, update_time, ssjh, create_by , update_by, remark, del_flag from t_run_curing_type_info where type = 2 and (ssjh = 3 or ssjh = 4)