mybatis xml 多条件多字段批量更新

  • 方式1:
    
        update ${tableName}
        
            
                ${key} = case guid
                
                    when #{item.guid} then #{item.${key}}
                
            
        
        where guid in
        
            #{item.guid}
        
        
            and mof = #{mof}
        
        
            and fiscal= #{fiscal}
        
    
  • 方式2:

        merge into ${tableName} t
        using (
        
            
                
                    #{item.${key}} as ${key}
                
            
        
        ) s
        on (t.guid = s.guid and t.mof = s.mofand t.fiscal = s.fiscal)
        when matched then
        update set
            
                
                    t.${key} = s.${key}
                
            
    

你可能感兴趣的:(mybatis,xml,java,oracle,mysql)