Closed zhangyufengg closed 4 weeks ago
使用的最新版本
咨询一下 将一段复杂的sql 作为子查询,然后子查询 字段 与实体类字段一致 。 别名为S .查询是按 表S 进行查询。
select * from ( SELECT t.id, t.apply_id applyId, t.caigou_lx caigouLx, CASE t.caigou_lx WHEN 1 THEN '统购' ELSE '自购' END caigouLxXsz, t.jiaohuo_qx jiaohuoQx, t.mat_id matId, t.mat_count matCount, t.mat_je matJe, t.remark, t.bianma, t.mat_code matCode, t.mingcheng, t.guige_xh guigeXh, t.danwei, t.chengben_jg chengbenJg, t.xiaoshou_jg xiaoshouJg, t.classification_id classificationId, t.classification_code classificationCode, t.own_id ownId, t.create_by createBy, t.create_name createName, t.gmt_create gmtCreate, t.update_by updateBy, t.update_name updateName, t.gmt_modifed gmtModifed, t.dept_id deptId, t.contracted_flag contractedFlag, t.dept_name deptName, t.address_detail addressDetail, t.contact, t.contact_number contactNumber, t.project_name projectName, t.eng_name engName, mca.apply_code, mca.project_type , CASE mca.project_type WHEN 0 THEN '联通总包' WHEN 1 THEN '联通总包自建' WHEN 3 THEN '发电机' ELSE '其他' END projectTypeXsz, mca.apply_name, mca.shenpi_zt, mca.apply_Date, mcc.supplier_name supplierName, mcc.supplier_dz supplierDz, mcc.lianxi_dh lianxiDh, ifnull(mccd.mat_count, 0) orderedQuantity, ifnull(t.mat_count, 0) - ifnull(mccd.mat_count, 0) unorderedQuantity, ifnull(mccd.mat_count, 0) - ifnull(mccd.current_count, 0) deliveredQuantity, ifnull(t.mat_count, 0) - (ifnull(mccd.mat_count, 0) - ifnull(mccd.current_count, 0)) undeliveredQuantity
FROM mat_cg_apply_detail t LEFT JOIN mat_cg_apply mca ON t.apply_id = mca.id LEFT JOIN mat_cg_unit_apply_detail mcuad ON mcuad.apply_detail_id = t.id LEFT JOIN mat_cg_contract_detail mccd ON mccd.apply_detail_id = mcuad.id LEFT JOIN mat_cg_contract mcc ON mccd.contract_id = mcc.id where t.caigou_lx = '1' union all SELECT t.id, t.apply_id applyId, t.caigou_lx caigouLx, CASE t.caigou_lx WHEN 1 THEN '统购' ELSE '自购' END caigouLxXsz, t.jiaohuo_qx jiaohuoQx, t.mat_id matId, t.mat_count matCount, t.mat_je matJe, t.remark, t.bianma, t.mat_code matCode, t.mingcheng, t.guige_xh guigeXh, t.danwei, t.chengben_jg chengbenJg, t.xiaoshou_jg xiaoshouJg, t.classification_id classificationId, t.classification_code classificationCode, t.own_id ownId, t.create_by createBy, t.create_name createName, t.gmt_create gmtCreate, t.update_by updateBy, t.update_name updateName, t.gmt_modifed gmtModifed, t.dept_id deptId, t.contracted_flag contractedFlag, t.dept_name deptName, t.address_detail addressDetail, t.contact, t.contact_number contactNumber, t.project_name projectName, t.eng_name engName, mca.apply_code, mca.project_type , CASE mca.project_type WHEN 0 THEN '总包' WHEN 1 THEN '总包自建' WHEN 3 THEN '发电机' ELSE '其他' END projectTypeXsz, mca.apply_name, mca.shenpi_zt, mca.apply_Date, mcoc.supplier_name supplierName, mcoc.supplier_dz supplierDz, mcoc.lianxi_dh lianxiDh, ifnull(mcocd.mat_count, 0) orderedQuantity, ifnull(t.mat_count, 0) - ifnull(mcocd.mat_count, 0) unorderedQuantity, ifnull(mcocd.mat_count, 0) - ifnull(mcocd.current_count, 0) deliveredQuantity, ifnull(t.mat_count, 0) - (ifnull(mcocd.mat_count, 0) - ifnull(mcocd.current_count, 0)) undeliveredQuantity FROM mat_cg_apply_detail t LEFT JOIN mat_cg_apply mca ON t.apply_id = mca.id LEFT JOIN mat_cg_own_apply_detail mcoad ON mcoad.apply_detail_id = t.id LEFT JOIN mat_cg_own_contract_detail mcocd ON mcocd.apply_detail_id = mcoad.id LEFT JOIN mat_cg_own_contract mcoc ON mcocd.contract_id = mcoc.id where t.caigou_lx = '2' )s <where> ${applyDetail.whereSql} </where>
咋${applyDetail.whereSql} 替换 成 MPJLambdaWrapper 能实现的。防止sql 注入
复杂sql建议写xml
当前使用版本(必填,否则不予处理)
使用的最新版本
该问题是如何引起的?(确定最新版也有问题再提!!!)
咨询一下 将一段复杂的sql 作为子查询,然后子查询 字段 与实体类字段一致 。 别名为S .查询是按 表S 进行查询。
重现步骤(如果有就写完整)
select * from ( SELECT t.id, t.apply_id applyId, t.caigou_lx caigouLx, CASE t.caigou_lx WHEN 1 THEN '统购' ELSE '自购' END caigouLxXsz, t.jiaohuo_qx jiaohuoQx, t.mat_id matId, t.mat_count matCount, t.mat_je matJe, t.remark, t.bianma, t.mat_code matCode, t.mingcheng, t.guige_xh guigeXh, t.danwei, t.chengben_jg chengbenJg, t.xiaoshou_jg xiaoshouJg, t.classification_id classificationId, t.classification_code classificationCode, t.own_id ownId, t.create_by createBy, t.create_name createName, t.gmt_create gmtCreate, t.update_by updateBy, t.update_name updateName, t.gmt_modifed gmtModifed, t.dept_id deptId, t.contracted_flag contractedFlag, t.dept_name deptName, t.address_detail addressDetail, t.contact, t.contact_number contactNumber, t.project_name projectName, t.eng_name engName, mca.apply_code, mca.project_type , CASE mca.project_type WHEN 0 THEN '联通总包' WHEN 1 THEN '联通总包自建' WHEN 3 THEN '发电机' ELSE '其他' END projectTypeXsz, mca.apply_name, mca.shenpi_zt, mca.apply_Date, mcc.supplier_name supplierName, mcc.supplier_dz supplierDz, mcc.lianxi_dh lianxiDh, ifnull(mccd.mat_count, 0) orderedQuantity, ifnull(t.mat_count, 0) - ifnull(mccd.mat_count, 0) unorderedQuantity, ifnull(mccd.mat_count, 0) - ifnull(mccd.current_count, 0) deliveredQuantity, ifnull(t.mat_count, 0) - (ifnull(mccd.mat_count, 0) - ifnull(mccd.current_count, 0)) undeliveredQuantity
咋${applyDetail.whereSql} 替换 成 MPJLambdaWrapper 能实现的。防止sql 注入
报错信息