我就废话不多说了,大家还是直接看代码吧~
int count =hrDeliverEmployContractService.selectCount(new EntityWrapper() .eq("pool_id",hrDeliverEmployContract.getPoolId()).andNew().lt("contract_start_date",hrDeliverEmployContract.getContractStartDate()).or().gt("contract_end_date",hrDeliverEmployContract.getContractEndDate()) );
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”);
select * from vehicle where (sim is null or sim='') and is_delete=‘0' QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper .eq(“name”,“测试”).or().eq(“sim”,“2”);
select * from vehicle where name=‘测试' or sim=‘2'
以上为个人经验,希望能给大家一个参考,也希望大家多多支持。如有错误或未考虑完全的地方,望不吝赐教。