当前位置:   article > 正文

QueryWrapper或和与连用方法_querywrapper 或者

querywrapper 或者

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"));
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 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)
  • 1

两头加了括号是因为用了and
此时在该queryWrapper对象上再加下面一条and

DPSQueryWrapper.eq(DailyProductionSchedulingPlan::getExampleId,exampleId);
  • 1

此时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 = ?)
  • 1

queryWrapper语法大全见 https://blog.csdn.net/qq_40448069/article/details/123214338?spm=1001.2014.3001.5501

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/158342
推荐阅读
相关标签
  

闽ICP备14008679号