SQL:根據主鍵判斷如果不存在插入,存在更新


SQL:根據主鍵判斷如果不存在插入,存在更新

<insert id="insertOrUpdate"  parameterType="Authshiming">
		insert into
		authshiming (
					authid ,
					paytype ,
					authmoney ,
					orderno,
					userid,
					authtype
					)
		values ( -- 如果主鍵不存在那么插入的內容
				#{authID},#{payType},#{authMoney},
				#{orderNo},#{userID},#{authType}
				)
		ON DUPLICATE KEY UPDATE -- 如果主鍵存在那么更新的內容
					paytype = #{payType},
					authmoney = #{authMoney},
					orderno= #{orderNo},
					userid= #{userID},
					authtype= #{authType},
					xingming_companyname = #{xingmingCompanyName},
					zhengjianno = #{zhengjianNo},
					zhengJianImg= #{zhengJianImg},
					phone = #{phone},
					shopname = #{shopName},
					province= #{province},
					city = #{city},
					area= #{area},
					address= #{address},
					latitude= #{latitude},
					longitude= #{longitude},
					paystate = #{payState},
					state= #{state},
					authdatetime= #{authDatetime},
					authFinishDatetime= #{authFinishDatetime},
					chatRoomID= #{chatRoomID},
					chatGroupsID= #{chatGroupsID},
					createtime= #{createtime},
					failMsg = #{failMsg},
					logoUrl= #{logoUrl}
	</insert>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM