<insert id="saveOrUpdate" parameterType="CmsStatisticsModel">
<selectKey keyProperty="count" resultType="int" order="BEFORE">
select count(*) as count from cms_user_statistics where user_id = #{userId}
</selectKey>
<if test="count>0">
update cms_user_statistics
<trim prefix="SET" suffixOverrides=",">
<if test="userName != null">user_name = #{userName},</if>
<if test="nickName != null">nick_name = #{nickName},</if>
<if test="email != null">email=#{email},</if>
<if test="membershipTime != null">membership_time = #{membershipTime},</if>
<if test="commentCount != null">comment_total #{commentTotal},</if>
</trim>
where user_id = userId
</if>
<if test="count==0">
insert into cms_user_statistics
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">user_id,</if>
<if test="userName != null">user_name,</if>
<if test="nickName != null">nick_name,</if>
<if test="email != null">email,</if>
<if test="membershipTime != null">membership_time,</if>
<if test="commentCount != null">comment_total,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">#{userId},</if>
<if test="userName != null">#{userName},</if>
<if test="nickName != null">#{nickName},</if>
<if test="email != null">#{email},</if>
<if test="membershipTime != null">#{membershipTime},</if>
<if test="commentTotal != null">#{commentTotal},</if>
</trim>
</if>
</insert>
根据条件删除重复数据
DELETE FROM zw_file WHERE file_id IN(
SELECT v.id FROM (SELECT MIN(b.file_id) id FROM zw_file b GROUP BY b.archive_url,b.file_name,b.archive_no,real_path HAVING COUNT(*) > 1) v)