1:分页列表
<sql id="sql_limit">
Limit #{startRow},#{pageSize}
</sql>
<sql id="order_by">
order by id desc
</sql>
<select id="totalRows" resultType="int" parameterType="map">
SELECT COUNT(0) from tc_skill_answer
<include refid="sql_where"></include>
</select>
<select id="selectList" parameterType="map" resultMap="SkillAnswerVo">
SELECT
<include refid="Base_Column_List"/>
,(select user_name from admin_user au where au.id = ts.audit_user) auditUserName
FROM tc_skill_answer ts
<include refid="sql_where"/>
<include refid="order_by"/>
<include refid="sql_limit"/>
</select>
<sql id="sql_where">
<where>
<if test="mid != null and mid > 0">
and mid = #{mid}
</if>
</where>
</sql>
2:模糊查询
name like CONCAT('%','${name}','%' )
3:大于小于SQL片段
<sql id="sql_where">
<where>
<if test="startTime != null">
<![CDATA[ AND giving_date > #{startTime}]]>
</if>
<if test="endTime != null">
<![CDATA[ AND giving_date < #{endTime}]]>
</if>
</where>
</sql>
4:主健返回
<insert id="insert" parameterType="com.platform.vo.WareSkuAttr" useGeneratedKeys="true" keyProperty="id"> </insert>