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>