`
y806839048
  • 浏览: 1091637 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

mybatis中使用if标签比较两个字符串是否相等

阅读更多

<!-- 此处使用if比较是否相等 -->

<select id="findClientIds" parameterType="map" resultType="map">

        SELECT sys_user.id,sys_user.clientId FROM sys_user
        <where>
            <if test="grade!= null and grade!= ''and grade == '3'.toString()">
                id =(
                SELECT PRIMARY_PERSON FROM sys_office WHERE id = 
                (SELECT office_id FROM sys_user WHERE id = #{userId}
                ))
            </if>
            <if test="grade!= null and grade!= '' and grade == '2'.toString()">
                id =(
                SELECT PRIMARY_PERSON FROM sys_office WHERE id = 
                (SELECT company_id FROM sys_user WHERE id = #{userId}
                ))
            </if>
            <if test="grade!= null and grade!= '' and grade == '1'.toString()">
                id = ''
            </if>
        </where>
    </select>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics