问题遇到的现象和发生背景
mybatis 增加一个if标签时就查询不到结果
增加type字段的if标签时
<select id="findInOutListByPage" resultType="com.ntvu.entity.InOut">
select tio.*, tg.`goodName` as goodName
from t_in_out tio
inner join t_good tg on tg.`id` = tio.`goodId`
<where>
<if test="goodName != null and goodName != ''">
and tg.goodName like concat('%',#{goodName},'%')
</if>
<if test="employeeName != null and employeeName != ''">
and tio.employeeName like concat('%',#{employeeName},'%')
</if>
<if test="startDate!=null">
<![CDATA[and tio.time>=#{startDate}]]>
</if>
<if test="endDate!=null">
<![CDATA[and tio.time<=#{endDate}]]>
</if>
<if test="type != null">
and tio.type = #{type}
</if>
</where>
order by tio.id = #{id}
</select>
运行结果
把type字段的if标签注释掉就可以查到结果了
我想要达到的结果
为什么会这样