mybatis动态循环拼接SQL,动态拼接字段 和动态拼接 LEFT JOIN
select T.BUSINESS_KEY_ "businessKey",D.JHBM "jhbm",D.JHBM || DO.DOC_NAME AS "designDoc",T.PROC_INST_ID_ "lcId",TO_CHAR( T.END_TIME_, 'yyyy-MM-dd hh24:mi:ss') "cjsj"< foreach collection = " mapList" item = " join" > ,decode(${join.tablename}.f_count, '', '未结构化', '已结构化') as "${join.tablename}",(SELECT TABLECHINESE FROM DOC_STRUCTURED_QUERY_CONFIG WHERE TABLENAME = '${join.tablename}')"${join.tablename}MC"</ foreach> FROM ACT_HI_PROCINST T< foreach collection = " mapList" item = " join" separator = " " > LEFT JOIN (select lcid, count(1) as f_countfrom ${join.tablename}group by lcid) ${join.tablename} ON T.PROC_INST_ID_ = ${join.tablename}.LCID</ foreach> LEFT JOIN V_DJJCXX DON D.JHDM = T.BUSINESS_KEY_LEFT JOIN DOC_FLOW_INSTANCE_INFO DION DI.PROCESS_INSTANCE_ID = T.PROC_INST_ID_LEFT JOIN DOC_INFO DOON DO.DOC_KEY = DI.DOC_KEY< where> D.JHBM IS NOT NULL< if test = " jhbm != null and jhbm != ''" > AND D.JHBM LIKE '%' || #{jhbm} || '%'</ if> </ where> ORDER BY T.END_TIME_