一觉睡到小时候

if标签语法

1
2
3
4
5
6
<select...>
SQL语句1
<if test="条件表达式">
SQL语句2
</if>
</select>

条件表达式中大于号小于号用 gt,lt

1
2
3
<if test="num gt 0">...</if>

<if test="num lt 0">...</if>

mapper

1
2
3
List<ZftjHalf> selectByAreaIdAndYear(@Param("areaId") String areaId,
@Param("year") String year,
@Param("level") int level);

##xml

1
2
3
4
5
6
7
8
9
10
11
12
13
<select id="selectByAreaIdAndYear" resultType="com.zftdata.nyzft.entity.ZftjHalf">
select * from ZFTJ_HALF
where FILLING_TIME LIKE CONCAT(#{year},'%')
<if test="level lt 3">
and AREA_ID_PID =#{areaId}
</if>
<if test="level gt 2">
and AREA_ID =#{areaId}
</if>
<if test="level == 4">
and AREA_ID =#{areaId}
</if>
</select>

简书
云+社区
掘金
CSDN
微信公共号:


 评论

载入天数...载入时分秒...