xml 文件中mybatis 的sql写法

like

方式一:

<if test="params.itemName != null and params.itemName != ''">
    and item_name like CONCAT('%',#{params.itemName},'%')
</if>

方式二:

<if test="params.itemName != null and params.itemName != ''">
    and item_name like '%' || #{params.itemName} || '%'
</if>

CDATA

<if test="createTimeStart != null">
    and create_time <![CDATA[ >= ]]>  #{createTimeStart}
</if>
<if test="createTimeEnd != null">
    and create_time <![CDATA[ < ]]> #{createTimeEnd}
</if>
posted @ 2024-01-24 11:44  品书读茶  阅读(18)  评论(0编辑  收藏  举报