赞
踩
sql 语句里and和or是有执行优先级的
mybatis-plus 提供的条件构造器但有时需要复杂嵌套写法的时候不能直接拼接
LambdaQueryWrapper<Report> wrapper = new LambdaQueryWrapper(reportQuery);
wrapper.ne(Report::getPeopleCounts, 0).or().ne(Report::getRemark, ""));
wrapper.ge(Report::getCreateTime,report.getStartDate())
.lt(Report::getCreateTime, report.getEndDate());
SELECT * FROM tb_report WHERE is_deleted =0 AND (
people_counts>0 OR remark !=''
AND create_time>='2022-10-18 12:00:00'
AND create_time<'2022-10-20 12:00:00')
LambdaQueryWrapper<Report> wrapper = new LambdaQueryWrapper(reportQuery);
wrapper.and(exportWrapper->exportWrapper.ne(Report::getPeopleCounts,0).or().ne(Report::getRemark, ""));
wrapper.ge(Report::getCreateTime,report.getStartDate())
.lt(Report::getCreateTime, report.getEndDate());
SELECT * FROM tb_report WHERE is_deleted =0 AND (
(people_counts>0 OR remark !='')
AND create_time>='2022-10-18 12:00:00'
AND create_time<'2022-10-20 12:00:00')
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。