怎么修改这句sql将 and COMP_CODE = #compCode or SIGN_COMP_CODE = #compCode里的等号改为in能够条件查询 select id=queryByCompCode resultType=comredxunhandovercoreentityHrWorkHandoverBasic parameterType=jav
要将等号改为in,可以使用以下方式修改SQL语句:
<select id="queryByCompCode" resultType="com.redxun.handover.core.entity.HrWorkHandoverBasic" parameterType="java.util.Map">
select ID_,REF_ID_,PARENT_ID_,UPDATE_VERSION_,DATE_IN_,WORK_ID_,NAME_,POST_NAME_,POST_CODE_,SLY_GRADE_,COMP_CODE,COMP_NAME,DEPT_NAME_,DEPT_ID_,LEAVE_OR_TRANSFER_,DATE_OUT_,TRANSFER_TIME_,LEAVE_INTERVIEW_ID,REASON_FOR_LEAVING_,HANDLED_BY_,TELEPHONE_,EMAIL,CONTACT_ADDRESS,DELETED_,INST_ID_,INST_STATUS_,ACT_INST_ID_,BUS_KEY_,TENANT_ID_,CREATE_TIME_,CREATE_BY_,UPDATE_BY_,UPDATE_TIME_,CREATE_DEP_ID_,COMPANY_ID_,CREATE_BY_NAME,UPDATE_BY_NAME,M_WORK_ID,CHECK_COMP,HANDOVER_PERSON_,REVIEWED_BY_,SIGN_COMP_CODE,SIGN_COMP_NAME,HANDOVER_PERSON_NAME,REVIEWED_BY_NAME,IDENTITY_ID,SigningAgent,SigningAgentName from w_work_handover_basic
<where>
<if test="@rx.Ognl@isNotEmpty(w.whereSql)">
${w.whereSql}
</if>
<if test="compCode != null">
and DELETED_ = 0
and (COMP_CODE in
<foreach collection="compCode" item="code" separator=",">
#{code}
</foreach>)
or (SIGN_COMP_CODE in
<foreach collection="compCode" item="code" separator=",">
#{code}
</foreach>)
</if>
</where>
<if test="@rx.Ognl@isNotEmpty(w.orderBySql)">
ORDER BY ${w.orderBySql}
</if>
<if test="@rx.Ognl@isEmpty(w.orderBySql)">
ORDER BY ID_ DESC
</if>
</select>
在上面的代码中,使用了foreach循环来遍历compCode,并将每个compCode作为参数传递给IN子句。注意,IN子句的语法是将各个值用逗号分隔,并用括号括起来
原文地址: https://www.cveoy.top/t/topic/ixhK 著作权归作者所有。请勿转载和采集!