美文网首页
常用sql的mybatis写法

常用sql的mybatis写法

作者: Pale_Eyes | 来源:发表于2019-04-26 13:50 被阅读0次

插入或者更新

    <insert id="active">
        INSERT INTO `csm`.`ms_device`
        (
        `createTime`,
        `modifyTime`,
        `regionId`,
        `deviceKey`,
        `activeTime`
        )
        VALUES
        (
        #{po.createTime},
        #{po.modifyTime},
        #{po.regionId},
        #{po.deviceKey},
        #{po.activeTime}
        )
        ON DUPLICATE KEY UPDATE activeTime = #{po.activeTime}
    </insert>

批量插入

    <insert id="createRegPhotos">
        INSERT IGNORE INTO `ms_reg_photo`
        (
        `personId`,
        `regPhotoUrl`,
        `createTime`
        )
        VALUES
        <foreach item="po" index="index" collection="pos" open="" separator="," close="">
            (
            #{po.personId},
            #{po.regPhotoUrl},
            #{po.createTime}
            )
        </foreach>
    </insert>

相关文章

网友评论

      本文标题:常用sql的mybatis写法

      本文链接:https://www.haomeiwen.com/subject/sivfnqtx.html