我就废话不多说了,大家还是直接看代码吧~
int count =hrDeliverEmployContractService.selectCount(new EntityWrapper<HrDeliverEmployContractEntity>() .eq("pool_id",hrDeliverEmployContract.getPoolId()).andNew().lt("contract_start_date",hrDeliverEmployContract.getContractStartDate()).or().gt("contract_end_date",hrDeliverEmployContract.getContractEndDate()) );
对应的SQL
SELECT COUNT(1) FROM hr_deliver_employ_contract WHERE (pool_id = 1) AND (contract_start_date < '2018-07-01 00:00:00.0' OR contract_end_date > '2018-10-31 00:00:00.0');
补充:mybatis plus or使用
QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper .and(wrapper -> wrapper.isNull(“sim”).or().eq(“sim”, “”)); queryWrapper .eq(“is_delete”, “0”);
对应sql语句
select * from vehicle where (sim is null or sim='') and is_delete=‘0' QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper .eq(“name”,“测试”).or().eq(“sim”,“2”);
对应sql语句
select * from vehicle where name=‘测试' or sim=‘2'
以上为个人经验,希望能给大家一个参考,也希望大家多多支持自学编程网。如有错误或未考虑完全的地方,望不吝赐教。
- 本文固定链接: https://zxbcw.cn/post/205290/
- 转载请注明:必须在正文中标注并保留原文链接
- QQ群: PHP高手阵营官方总群(344148542)
- QQ群: Yii2.0开发(304864863)