直接查询没有问题,设置了查询条件,加入查询条件就报错!求大神指点!

select co.name AS ssgs, gr.name AS fzlb, cy.name AS lcmc,c.subject AS zt,c.createTime as lcfqsj,s.contractid as htid,c.creatorName AS cjr,e.companyname as cjrbm,s.tenantName as qyrzt,s.receiverName as jsr,c.createTime,c.comments,a.name,a.tenantname as qsr,a.completetime as qssj ,

if ( c.status='COMPLETE','完成','未完成') as status

        from COMPANY co

            left join CATEGORY_GROUP gr on gr.companyId = co.id

            left join CATEGORY cy on cy.groupId = gr.id

            inner join CONTRACT c  on c.categoryid=cy.id   

            inner join SIGNATORY s on s.contractid=c.id   

            inner join ACTION a on a.signatoryId =s.id   

            left join EMPLOYEE f on f.userid=c.creatorId

           left join EMPLOYEE_DEPARTMENT h on f.id=h.employeeid

      left join DEPARTMENT e  on co.id=e.companyid   and e.id= h.departmentid where c.status <> 'DRAFT' and c.status <> 'EXPIRED' and c.status <> 'FILLING' and c.status <> 'FILLING' and c.status <> 'DELETE'  AND e.type = 'SECTION' 

${if(len(所属公司) == 0,"","and ssgs = '" + 所属公司 + "' ")}

${if(len(分组类别) == 0,"","and fzlb = '" + 分组类别 + "' ")}

${if(len(流程名称) == 0,"","and lcmc = '" + 流程名称 + "' ")}

image.png

FineReport 李昌海 发布于 2021-8-10 10:01 (编辑于 2021-8-10 10:34)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共3回答
最佳回答
0
linbodingLv6中级互助
发布于2021-8-10 10:02(编辑于 2021-8-10 10:15)

where  1=1 

${if(len(分组类别) == 0,"","and fzlb in( '" + 分组类别 + "') ")}

复选框间隔符   用‘,’

image.png

最佳回答
0
snrtuemcLv8专家互助
发布于2021-8-10 10:02(编辑于 2021-8-10 10:04)

~~~~~~

最佳回答
0
烟尘Lv6高级互助
发布于2021-8-10 10:02(编辑于 2021-8-10 10:04)

错误提示是ssgs不是字段,看起来跟加的查询没关系,完整代码发出来

如果分组类别是多选框的话,就要用in,返回字符串,分隔符','

${if(len(分组类别) == 0,""," and fzlb in ('" + 分组类别 + "') ")}

  • 4关注人数
  • 268浏览人数
  • 最后回答于:2021-8-10 10:34
    请选择关闭问题的原因
    确定 取消
    返回顶部