动态拼写sql方法模糊查询,需要concat拼接一下,concat(‘%‘,#{name},‘%‘)

{"<script>",
        "select name from tablename where 1=1 ",
        "<if test=\"name != null and name != ''\">",
        "and name like concat('%',#{name},'%') ",
        "</if>",
        "<if test=\"orders != null and orders != ''\">",
        " order by ${orders}",
        "</if>",
        "<if test='offset != null and rows != null'>",
        " limit #{offset}, #{rows}",
        "</if>",
"</script>"}

利用{"<script>" "</script>"}方法模糊查询,需要concat拼接一下,concat('%',#{name},'%')

排序字段前要用$

limit 分页

Preparing: SELECT count(0) FROM ICDPUB.T_C_DY_MODELNODE_BIND bind JOIN T_UUM_ORGANIZATION org ON bind.bind_org = org.ORGNO JOIN t_c_dy_workgroup wg ON bind.bind_value = wg.GROUP_ID WHERE bind.BUSINESS_KEY = ? AND bind.NODE_ID = ? AND wg.GROUP_NAME LIKE CONCAT(&#39;%&#39;, ?, &#39;%&#39;) AND org.ORGNAME LIKE CONCAT(&#39;%&#39;, ?, &#39;%&#39;) AND bind.BIND_ROLE LIKE CONCAT(&#39;%&#39;, ?, &#39;%&#39;) 17:07:47.738 [http-nio-8093-exec-3] DEBUG c.h.s.s.m.D.queryByCases_COUNT - ==> Parameters: PROVINCE_UPGRADE_ADVANCED(String), dskfbjl-ys(String), 滨州(String), 滨州(String), 区县(String) 17:07:53.776 [http-nio-8093-exec-3] DEBUG o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver - Using @ExceptionHandler public com.alibaba.fastjson.JSONObject com.huawei.sdcmdy.config.GlobalExceptionHandler.exceptionHandler(javax.servlet.http.HttpServletRequest,java.lang.Exception) 17:07:53.790 [http-nio-8093-exec-3] ERROR c.h.s.config.GlobalExceptionHandler - Exception @<http://websdcmdy/sdcmdy/dy/processNode/queryOrgList>,cause is: org.springframework.jdbc.BadSqlGrammarException: ### Error querying database. Cause: java.sql.SQLSyntaxErrorException: ORA-00909: 参数个数无效,结合SELECT wg.GROUP_ID AS groupId, wg.GROUP_NAME AS groupName, org.ORGNO AS orgId, org.ORGNAME AS orgName, bind.BIND_ROLE AS levelName, bind.BUSINESS_KEY AS businessKey, bind.NODE_ID AS nodeId FROM ICDPUB.T_C_DY_MODELNODE_BIND bind JOIN T_UUM_ORGANIZATION org ON bind.bind_org = org.ORGNO JOIN t_c_dy_workgroup wg ON bind.bind_value = wg.GROUP_ID WHERE bind.BUSINESS_KEY = #{dyProcessNodeOrgBindedListDTO.businessKey} AND bind.NODE_ID = #{dyProcessNodeOrgBindedListDTO.nodeId} <if test="dyProcessNodeOrgBindedListDTO.groupName != &#39;&#39; and dyProcessNodeOrgBindedListDTO.groupName != null"> AND wg.GROUP_NAME LIKE CONCAT(&#39;%&#39;,#{dyProcessNodeOrgBindedListDTO.groupName},&#39;%&#39;) </if> <if test="dyProcessNodeOrgBindedListDTO.orgName != &#39;&#39; and dyProcessNodeOrgBindedListDTO.orgName != null"> AND org.ORGNAME LIKE CONCAT(&#39;%&#39;,#{dyProcessNodeOrgBindedListDTO.orgName},&#39;%&#39;) </if> <if test="dyProcessNodeOrgBindedListDTO.levelName != &#39;&#39; and dyProcessNodeOrgBindedListDTO.levelName != null"> AND bind.BIND_ROLE LIKE CONCAT (&#39;%&#39;,#{dyProcessNodeOrgBindedListDTO.levelName},&#39;%&#39;)什么原因 </if>
07-02
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值