sql语句拼接mybatis教程
<select id="xxxxxxxxbyall" resulttype="xxx.xxx.xxxxxx.xx.xxx.xxxxxxxxxx"> select cc.* from cp_claim_customer cc <if test="supplier_result != null or supplier_status != null or submit_time1 != null or submit_time2 != null or supplier_delivery_time1 != null or supplier_delivery_time2 != null or supplier_claim_amount1 != null or supplier_claim_amount2 != null or supplier_is_return != null or supplier_accounts_code != null or supplier_delivery_code != null"> join cp_claim_supplier cs on cc.claim_supplier_code = cs.claim_supplier_code if> <where> <if test="claim_customer_code != null"> cc.claim_customer_code=#{claim_customer_code} if> <if test="material_code != null"> and cc.material_code=#{material_code} if> <if test="status != null"> and cc.status=#{status} if> <if test="accounts_code != null"> and cc.accounts_code=#{accounts_code} if> <if test="type != null"> and cc.type=#{type} if> <if test="approval_result != null"> and cc.approval_result=#{approval_result} if> <if test="supplier_result != null"> and cs.supplier_result=#{supplier_result} if> <if test="supplier_status != null"> and cs.supplier_status=#{supplier_status} if> <if test="claim_supplier_code != null"> and cs.claim_supplier_code=#{claim_supplier_code} if> <if test="create_time1 != null and create_time2 != null"> and cc.create_time between #{create_time1} and #{create_time2} if> <if test="responsible_party_type != null"> and cc.responsible_party_type=#{responsible_party_type} if> <if test="tech_act_batchcode != null"> and cc.tech_act_batchcode=#{tech_act_batchcode} if> <if test="delivery_order_code != null"> and cc.delivery_order_code=#{delivery_order_code} if> <if test="delivery_order_time1 != null and delivery_order_time2 != null"> and cc.delivery_order_time between #{delivery_order_time1} and #{delivery_order_time2} if> <if test="claim_survey != null"> and cc.claim_survey=#{claim_survey} if> <if test="material_name != null"> and cc.material_name=#{material_name} if> <if test="is_tosupplier != null"> and cc.is_tosupplier=#{is_tosupplier} if> <if test="claim_amount1 != null and claim_amount2 != null"> and cc.claim_amount between #{claim_amount1} and #{claim_amount2} if> <if test="claim_amount1 == null and claim_amount2 != null"> and cc.claim_amount = #{claim_amount2} if> <if test="claim_amount1 != null and claim_amount2 == null"> and cc.claim_amount = #{claim_amount1} if> <if test="is_return != null"> and cc.is_return=#{is_return} if> <if test="is_scrap != null"> and cc.is_scrap=#{is_scrap} if> <if test="supplier_claim_amount1 != null and supplier_claim_amount2 != null"> and cs.claim_amount between #{supplier_claim_amount1} and #{supplier_claim_amount2} if> <if test="supplier_claim_amount1 != null and supplier_claim_amount2 == null"> and cs.claim_amount = #{supplier_claim_amount1} if> <if test="supplier_claim_amount1 == null and supplier_claim_amount2 != null"> and cs.claim_amount = #{supplier_claim_amount2} if> <if test="supplier_is_return != null"> and cs.return_status=#{supplier_is_return} if> <if test="supplier_accounts_code != null"> and cs.accounts_code=#{supplier_accounts_code} if> <if test="supplier_delivery_code != null"> and cs.supplier_delivery_code=#{supplier_delivery_code} if> <if test="submit_time1 != null and submit_time2 != null"> and cs.submit_time between #{submit_time1} and #{submit_time2} if> <if test="supplier_delivery_time1 != null and supplier_delivery_time2 != null"> and cs.supplier_delivery_time between #{supplier_delivery_time1} and #{supplier_delivery_time2} if> where> order by cc.id desc select>