1、mybatis中if-else语句的语法
使用模板样例
<choose> //模块
<when test="变量== 1 "> //if语句
执行语句 //是-执行语句
</when>
<otherwise> //否则
执行语句 //否-执行语句
</otherwise>
</choose> //结束
例子:
select
count(0)
from
tb_user u
where
u.user_state=0
<choose>
<when test="typeId == 1 ">
and u.company_id is not null
</when>
<otherwise>
and u.company_id is null
</otherwise>
</choose>