动态SQL
# 查询name包含丽丽,且age大于18的用户
select * from tb_user where name like '%丽丽%' and age > 18;
# 查询name包含丽丽
select * from tb_user where name like '%丽丽%';
# 查询age大于18的用户
select * from tb_user where age > 18;
# 查询所有用户
select * from tb_user;if
<select id="selectUser" resultType="User">
select * from tb_user where 1=1
<if test="name != null and name != ''">
and name like concat('%',#{name},'%')
</if>
<if test="age != null and age != ''">
and age > #{age}
</if>
</select>where 标签
trim
choose、when、otherwise
foreach
sql
最后更新于