赞
踩
or和and括号并用
代码:
LambdaQueryWrapper<DailyProductionSchedulingPlan> DPSQueryWrapper=new LambdaQueryWrapper<>();
DPSQueryWrapper.and(QueryWrapper->QueryWrapper.eq(DailyProductionSchedulingPlan::getProductionStatus,"2")
.or().eq(DailyProductionSchedulingPlan::getProductionStatus,"3")
.or().eq(DailyProductionSchedulingPlan::getProductionStatus,"4")
.or().eq(DailyProductionSchedulingPlan::getProductionStatus,"5")
.or().eq(DailyProductionSchedulingPlan::getProductionStatus,"6")
.or().eq(DailyProductionSchedulingPlan::getProductionStatus,"7"));
对应的sql查询条件为
(production_status = 2 OR production_status = 3 OR production_status = 4 OR production_status = 5 OR production_status = 6 OR production_status = 7)
两头加了括号是因为用了and
此时在该queryWrapper对象上再加下面一条and
DPSQueryWrapper.eq(DailyProductionSchedulingPlan::getExampleId,exampleId);
此时SQL变为了
((production_status = 2 OR production_status = 3 OR production_status = 4 OR production_status = 5 OR production_status = 6 OR production_status = 7) AND example_id = ?)
queryWrapper语法大全见 https://blog.csdn.net/qq_40448069/article/details/123214338?spm=1001.2014.3001.5501
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。