我需要的语句是这样的效果
select * from SHANGPIN WHERE isnull(tzsy,0) = 0 AND (spdm = '000' OR (spdm <> '000' AND spmc = '测试'))
我们用mybatisplus 直接写这样的话
QueryWrapper<EKehu> wrapper=new QueryWrapper<>();
wrapper.eq("isnull(tzsy,0)",0);
wrapper.eq("spdm","000");
wrapper.or(wp1->wp1.ne("spdm","000").eq("spmc","测试"));
System.out.println(wrapper.getCustomSqlSegment());
显示的效果是这样的,这就不是我想要的效果
我需要用and去将这后面的条件括起来
QueryWrapper<EKehu> wrapper=new QueryWrapper<>();
wrapper.eq("isnull(tzsy,0)",0);
wrapper.and(wp->wp.eq("spdm","000").or(wp1->wp1.ne("spdm","000").eq("spmc","测试")));
System.out.println(wrapper.getCustomSqlSegment());
这样的才是我想要的样子