sql中使用判断,如果—否者

  • Post author:
  • Post category:其他


<select id=”getMerchantCount” parameterType=”com.ssay.merchant.search.MerchantBean” resultType=”INTEGER”>

SELECT

count(1)

FROM

`t_sys_merchant` AS m

WHERE m.`del` = ‘1’

AND m.`enable` = ‘1’


<choose>

<when test=”merchantType != null”>

and m.merchant_type = #{merchantType}

</when>

<otherwise>

and m.merchant_type = 0

</otherwise>

</choose>


<if test=” startDate != null and startDate != ” “>

AND m.`create_time` &gt;=  #{startDate}

</if>

<if test=” endDate != null and endDate != ” “>

AND m.`create_time` &lt;= #{endDate}

</if>

<if test=” merchantCode != null and merchantCode != ” “>

AND m.`merchant_code` = #{merchantCode}

</if>

<if test=” merchantName != null and merchantName != ” “>

AND m.`merchant_name`  like”%”#{merchantName}”%”

</if>

</select>



版权声明:本文为qq_34295227原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。