Mybaits 动态查询数据库 汇总
<select id="selectBrandListByQuery" parameterType="BrandQuery" resultMap="brand">
select id , name ,description,img_url,sort,is_display
from bbs_brand
<where>
<if test="name != null">
name like "%"#{name}"%"
</if>
<if test="isDisplay != null">
and is_display = #{isDisplay}
</if>
</where>
<if test="startRow != null">
limit #{startRow},#{pageSize}
</if>
</select>
其中isDisplay表示传入的java属性,
is_display是表示数据库中表的属性
%代表任意多个字符 _代表一个字符