有时候,我们不想使用所有的条件,而只是想从多个条件中选择一个使用,它有点像 Java 中的 switch 语句。
- 接口类
//按照不同的需求查询
List<Blog> queryBlogChoose(Map map);
- Mapper.xml配置文件
<select id="queryBlogChoose" parameterType="map" resultType="Blog">
select * from blog
<where>
<choose>
<when test="title!=null">
title=#{title}
</when>
<when test=