Mybatis实现多个或条件查询

实现
SELECT * FROM table where tag_id =382 or tag_id =381 ;

mapper层示例:

<select id="queryByxxId" resultType="xxDAO">
    SELECT id,
    <include refid="select_columns"/>
    FROM
    table
    <where>
        <if test="xxId!=null">
            xx_id = #{xxId} OR
        </if>
        <if test="xxxTagId!=null">
            xx_id = #{xxxTagId}   OR
        </if>
        <if test="xxxxTagId!=null">
            xx_id = #{xxxxTagId}
        </if>
    </where>
    ORDER BY gmt_modified DESC
</select>
发布了126 篇原创文章 · 获赞 46 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/loulanyue_/article/details/100672087