myBatis针对不同数据库的模糊查询
<if test="name != null and name != ''"> AND a.name LIKE <if test="dbName == 'oracle'">'%'||#{name}||'%'</if> <if test="dbName == 'mssql'">'%'+#{name}+'%'</if> <if test="dbName == 'mysql'">concat('%',#{name},'%')</if> </if>
遇到分类树结构,删除时如果有下级,则将下级也删除
<update id="delete"> DELETE FROM dm_model_type WHERE id = #{id} OR parent_ids LIKE '%,'||#{id}||',%' </update>