打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
插入(Insert)SQL可动态设置字段属性

如图:合理运用动态sql,也可随意控制插入字段信息,代码中只对appVersion和userMobile赋值,

<insert id="insertDataPointInfo" keyColumn="id" keyProperty="id" useGeneratedKeys="true">
        INSERT INTO data_point_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="itemId != null">
                item_id,
            </if>
            <if test="distinctId != null">
                distinct_id,
            </if>
            <if test="userId != null">
                user_id,
            </if>
            <if test="username != null">
                user_name,
            </if>
            <if test="userMobile != null">
                user_mobile,
            </if>
            <if test="os != null">
                os,
            </if>
            <if test="osVersion != null">
                os_version,
            </if>
            <if test="appVersion != null">
                app_version,
            </if>
            <if test="ip!= null">
                ip,
            </if>
            <if test="opTime!= null">
                op_time,
            </if>
        </trim>
        VALUES
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="itemId != null">
                #{itemId,jdbcType=INTEGER},
            </if>
            <if test="distinctId != null">
                #{distinctId,jdbcType=VARCHAR},
            </if>
            <if test="userId != null">
                #{userId,jdbcType=VARCHAR},
            </if>
            <if test="username != null">
                #{username,jdbcType=VARCHAR},
            </if>
            <if test="userMobile != null">
                #{userMobile,jdbcType=VARCHAR},
            </if>
            <if test="os != null">
                #{os,jdbcType=VARCHAR},
            </if>
            <if test="osVersion != null">
                #{osVersion,jdbcType=VARCHAR},
            </if>
            <if test="appVersion != null">
                #{appVersion,jdbcType=VARCHAR},
            </if>
            <if test="ip != null">
                #{ip,jdbcType=VARCHAR},
            </if>
            <if test="opTime != null">
                #{opTime},
            </if>
        </trim>
    </insert>
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
书接上文:薛定谔的猫是如何诞生的?
wm_concat函数
如何给SQL查询添加合计行(1)
DELETE CASCADE级联删除
SQL语句(建库、建表、修改语句)
mysql常识和基本操作
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服