<choose>
<when test="rq.timeType != null and rq.timeType == 'createTime'">
<if test="rq.startTime != '' and rq.startTime != null">
and s.createTime >= #{rq.startTime}
</if>
<if test="rq.endTime != '' and rq.endTime != null">
and s.createTime <= #{rq.endTime}
</if>
</when>
<when test="rq.timeType != null and rq.timeType == 'salesTime'">
<if test="rq.startTime != '' and rq.startTime != null">
and s.salesTime >= #{rq.startTime}
</if>
<if test="rq.endTime != '' and rq.endTime != null">
and s.salesTime <= #{rq.endTime}
</if>
</when>
<when test="rq.timeType != null and rq.timeType == 'verifyTime'">
<if test="rq.startTime != '' and rq.startTime != null">
and s.verifyTime >= #{rq.startTime}
</if>
<if test="rq.endTime != '' and rq.endTime != null">
and s.verifyTime <= #{rq.endTime}
</if>
</when>
<otherwise>
<if test="rq.startTime != '' and rq.startTime != null">
and s.salesTime >= #{rq.startTime}
</if>
<if test="rq.endTime != '' and rq.endTime != null">
and s.salesTime <= #{rq.endTime}
</if>
</otherwise>
</choose>
Multiple time types (such as creation time, review time), how to implement it in SQL (use <choose> </choose>)
Guess you like
Origin blog.csdn.net/linyiwwy/article/details/132166177
Recommended
Ranking