mybatis中if标签判断字符串相等

错误写法

    <select id="selectBookCountByOrgId" resultType="java.lang.Integer">
        SELECT count(*) FROM book WHERE org_id IN
        (
        <if test="orgId != '0'">
            #{orgId},
        </if>
        '0'
        )
         AND del = 0
    </select>


正确写法

    <select id="selectBookCountByOrgId" resultType="java.lang.Integer">
        SELECT count(*) FROM book WHERE org_id IN
        (
        <if test="orgId != '0'.toString()">
            #{orgId},
        </if>
        '0'
        )
         AND del = 0
    </select>

猜你喜欢

转载自blog.csdn.net/weixin_39973810/article/details/85635200