File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ title: Mybatis if标签判断数字大小
2
+ tags:
3
+ - MyBatis
4
+ categories:
5
+ - Dev
6
+ - Java
7
+ date: 2020-03-18 14:01:00
8
+ cover: true
9
+
10
+ ---
11
+
12
+ ![ ] ( http://q6pznk9ej.bkt.clouddn.com/fish.jpg )
13
+ <!-- more -->
14
+ ## if标签语法
15
+ ```
16
+ <select...>
17
+ SQL语句1
18
+ <if test="条件表达式">
19
+ SQL语句2
20
+ </if>
21
+ </select>
22
+ ```
23
+
24
+ ## 条件表达式中大于号小于号用 gt,lt
25
+ ```
26
+ <if test="num gt 0">...</if>
27
+
28
+ <if test="num lt 0">...</if>
29
+ ```
30
+
31
+ ## mapper
32
+ ```
33
+ List<ZftjHalf> selectByAreaIdAndYear(@Param("areaId") String areaId,
34
+ @Param("year") String year,
35
+ @Param("level") int level);
36
+ ```
37
+
38
+ ##xml
39
+ ```
40
+ <select id="selectByAreaIdAndYear" resultType="com.zftdata.nyzft.entity.ZftjHalf">
41
+ select * from ZFTJ_HALF
42
+ where FILLING_TIME LIKE CONCAT(#{year},'%')
43
+ <if test="level lt 3">
44
+ and AREA_ID_PID =#{areaId}
45
+ </if>
46
+ <if test="level gt 2">
47
+ and AREA_ID =#{areaId}
48
+ </if>
49
+ <if test="level == 4">
50
+ and AREA_ID =#{areaId}
51
+ </if>
52
+ </select>
53
+ ```
You can’t perform that action at this time.
0 commit comments