java代码拼写sql

java后台   
String zffwdm=map.get("zffwmc")==null?"":map.get("zffwmc");
        if(!"".equals(zffwdm)){
        String zffwdms []=zffwdm.split(",");
        String sql="(";
        for(int i=0;i<zffwdms.length;i++){
            sql+="instr(zffwdm,'"+zffwdms[i].trim()+"')>0";
            //      instr(zffwdm,'08')>0 
            if(i != zffwdms.length-1){
                sql += " or ";
            }
        }
        sql += ")";
        map.put("sql",sql);
        }
 
 xml里面拼写的
 
        select
              a.userid,
              b.user_name,
              (select dept.dep_name from sys_right_department dept where dept.sys_right_department_id=d.dep_belon_unit_code) dwmc,
               d.dep_name bmmc,
              b.zfbh,
            a.zffwmc
        from jdjc_zfry a ,sys_right_user b,sys_right_department d
    where a.userid=b.sys_right_user_id
          and b.dep_code=d.sys_right_department_id
          <isNotEmpty prepend="" property="sql">
                <isNotEqual compareValue="" prepend="and"
                    property="sql">
                    $sql$
                </isNotEqual>
            </isNotEmpty>
        <include refid="queryJcryglCondition"/>
posted @ 2019-04-10 19:00  那些年的代码  阅读(1330)  评论(0编辑  收藏  举报