zoukankan      html  css  js  c++  java
  • mybatis 批量操作 ------持续更新

    mybatis 不存在则才进行添加

    # 添加的 sql 语句
    insert into sys_link_post_user(post_id,user_id)
    # 进行批量添加 (若不需要可以取消 froeach 标签 ),最重要的事 separator='UNION ALL'
    <foreach collection="userIds" item="userid" index="index" separator="UNION ALL" >
            # DUAl 是一张临时表,直接可以用,然后 where not exists 中写子查询,若存在(select #{postId},#{userid} from 结果将为空)
                select #{postId},#{userid} from DUAL where not exists( select user_id  from sys_link_post_user where user_id = #{userid} )
            </foreach>
  • 相关阅读:
    今日总结
    今日总结
    今日总结
    今日总结
    今日总结
    今日总结
    今日总结
    今日总结
    今日总结
    Interesting Finds: 2010 02.08 ~ 02.13
  • 原文地址:https://www.cnblogs.com/zhangzhonghui/p/11721413.html
Copyright © 2011-2022 走看看