4种标签:

1. if

2. choose (when, otherwise)

3. trim (where, set)

4. foreach

1.

  1. <where> // 标签
  2. and 写在语句之前

for.png

2.

优点: 可以避免if标签中 and 冗余

image.png

3.

image.png

4.

image.png

5.

sql: select * from tbl_employee where id in (1,2,3);

image.png

6. bind标签 _lastName

在like查询中, eg: select * from employee where lastName like #{}
,此时, #{} 是一个完整的字符串,不能拼接。 所以需要提前拼接,通过_lastName引用的形式传值

1653833401(1).png

7. sql标签 include

作用: 抽取可以重复使用的sql片段,方便后续引用

image.png