mybatis中mysql ON DUPLICATE KEY UPDATE写法

    

<insert id="batchInsertFansInfo" parameterType="java.util.List">
		INSERT INTO fans
		(fansId,userId,openId,headImg,signature,commentName,nickname,sex,age,
		country,province,city,subscribeTime,cancelSubtime,isCoincide,
		groupId,phone,email,memo,updateTime,deleteFlag)
		VALUES
		<foreach collection="list" item="item" index="index" separator=",">
			(#{item.fansId},#{item.userId},#{item.openId},#{item.headImg},#{item.signature},#{item.commentName},#{item.nickname},
			#{item.sex},#{item.age},#{item.country},#{item.province},#{item.city},#{item.subscribeTime},
			#{item.cancelSubtime},#{item.isCoincide},#{item.groupId},#{item.phone},#{item.email},#{item.memo},
			#{item.updateTime},#{item.deleteFlag})
	    </foreach>
		ON DUPLICATE KEY UPDATE
			userId = VALUES(userId),
			openId = VALUES(openId),
			headImg = VALUES(headImg),
			signature = VALUES(signature),
			commentName = VALUES(commentName),
			nickname = VALUES(nickname),
			sex = VALUES(sex),
			age = VALUES(age),
			country = VALUES(country),
			province = VALUES(province),
			city = VALUES(city),
			subscribeTime = VALUES(subscribeTime),
			cancelSubtime = VALUES(cancelSubtime),
			isCoincide = VALUES(isCoincide),
			groupId = VALUES(groupId),
			phone = VALUES(phone),
			email = VALUES(email),
			memo = VALUES(memo),
			updateTime = VALUES(updateTime),
			deleteFlag = VALUES(deleteFlag)
	</insert>


你可能感兴趣的:(mybatis,update,on,key,DUPLICATE)