<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` >= #{startDate}
</if>
<if test=" endDate != null and endDate != '' ">
AND m.`create_time` <= #{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>
sql中使用判断,如果---否者
最新推荐文章于 2024-03-29 21:49:42 发布