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

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐