mybatis插入數據(無則插入有則更新)以及字段自增

參考鏈接:

https://blog.csdn.net/hongtaolong/article/details/88343738

https://blog.csdn.net/definitly/article/details/82969245

https://www.runoob.com/mysql/mysql-index.html(MySQL 索引)

https://www.w3school.com.cn/sql/sql_unique.asp(SQL UNIQUE 約束)

https://blog.csdn.net/antony9118/article/details/72576199


<insert id="insertUser"  useGeneratedKeys="true" keyProperty="id" keyColumn="id"
            parameterType="com.foreigners.entity.User">
        insert INTO
        t_user(openId, name, gender, phoneNumber)
        VALUES
        (#{openId},#{name},#{gender},#{phoneNumber})
        ON DUPLICATE KEY UPDATE
        name = #{name},
        gender = #{gender},
        phoneNumber = #{phoneNumber}
</insert>

MySQL新增數據,存在就更新,不存在就添加(Mybatis)

https://blog.csdn.net/CNAHYZ/article/details/88786117

 

發佈了95 篇原創文章 · 獲贊 44 · 訪問量 20萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章