当查询的动态SQL条件中需要用到if else语句格式的时候需要用到choose标签
格式举例
<select id="query2Emp" parameterType="Employee" resultMap="employeeResultMap">
select
t_id,
t_name,
t_age,
t_birthday,
t_salary
from t_employee
<where>
<choose>
<when test="name!=null">
and t_name=#{name}
</when>
<otherwise>
and t_name="dd"
</otherwise>
</choose>
</where>
</select>
when标签相当于if
第二个when相当于
if else if
otherwise是不满足之前的条件下