NutzCN Logo
问答 查询条件后追加and().or();,会导致前面查询条件失效么?
发布于 8天前 作者 Somuns 51 次浏览 复制 上一个帖子 下一个帖子
标签:
        Cnd cnd = FunctionUtils.MapToCnd(params);
        cnd.and("check_parent_orgid","=", RuntimeUtils.getOrgId());
        cnd.or("check_org_id","=", RuntimeUtils.getOrgId());
"SELECT COUNT(*) FROM reporting_info  WHERE 1=1 AND report_level=6 AND month='1' AND year='2017' AND check_state IN ('已通过','未通过','审核中') AND check_parent_orgid=5410 OR check_org_id=5410"

查询出来的结果,出现了month不匹配,check_state不匹配情况

5 回复

你需要的是 where (a = 1 and b = 2) or c = 3 这种语句??

where report_level=6 AND month='1' AND year='2017' AND( a=1 OR b = 1)

        Cnd cnd = FunctionUtils.MapToCnd(params);
        cnd.and(Cnd.exps("check_parent_orgid","=", RuntimeUtils.getOrgId().or("check_org_id","=", RuntimeUtils.getOrgId()));

        Cnd cnd = FunctionUtils.MapToCnd(params);
        cnd.and(Cnd.exps("check_parent_orgid","=", RuntimeUtils.getOrgId()).or("check_org_id","=", RuntimeUtils.getOrgId()));

嗯嗯,可以了,谢谢了,兽总

添加回复
请先登陆
回到顶部