插入一条不重复的数据

insert into sys_user (username, password, likeName,
        imgurl, email, mobile,
        userType, remark, enabledFlag,
        creattime, updatetime,lastPasswordTime,`rank`,score,balance,referrerId,referrer,source,gender,
        openId,address,skey,sessionKey,age)
        select #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{likename,jdbcType=VARCHAR},
        #{imgurl,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR},
        #{usertype,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{enabledflag,jdbcType=INTEGER},
        #{creattime,jdbcType=TIMESTAMP}, #{updatetime,jdbcType=TIMESTAMP}
        ,#{lastPasswordTime},#{rank},#{score},#{balance},#{referrerid}
        ,#{referrer},#{source},#{gender},#{openId},#{address},#{skey},#{sessionKey},#{age}
        from DUAL
        where NOT EXISTS( SELECT openId FROM sys_user WHERE openId = #{openId})

你可能感兴趣的:(ssm)