Mybatis中sql语句的条件查询
sql语句中,常用的条件查询Mybatis
开始时间和结束时间的约束>=和<
select * from 表名
<where>
<if test="startTime != null "> and start_time >= #{startTime}</if>
<if test="endTime != null "> and end_time < #{endTime}</if>
</where>
模糊查询,用like concat()
<if test="alertContent != null and alertContent != ''"> and alert_content like concat('%', #{alertContent}, '%')</if>