Mybatis 中的insertOrUpdate操作

无情的你无情的雨 2020-04-21

<insert id="insertOrUpdate">
 insert into base_person
       (pname, idcard, gender, nation, source_flag, create_time)
    values
    <foreach collection="list" item="p" index="index" separator=",">
        (#{p.pname},
        #{p.idcard},
        #{p.gender},
        #{p.nation},
        #{p.sourceFlag},
        #{p.createTime})
    </foreach>
    ON DUPLICATE KEY UPDATE
        pname=values(pname),
        idcard=values(idcard),
        gender=values(gender),
        nation=values(nation)
</insert>

相关推荐

lightlanguage / 0评论 2020-04-22