Mybatis 使用<update>中<set>标签的简明例子

注:xxx为某某某的意思

        update xxx
        
            
                SQL1,
            
            
                SQL2,
            
        
        where SQL3

如果成立,不成立

则最终SQL语句为 update xxx set SQL1 where SQL3;

会自动去掉SQL1,尾部的逗号,并加上set

如果均成立

则最终SQL语句为 update xxx set SQL1, SQL2 where SQL3;

实际例子

UPDATE table_name SET column1 = value1, column2 = value2  WHERE id=36;

逗号里判断后结果不能为空,否则SQL语句语法错误

对于,同>一样可以用<trim>代替

        update xxx
        
            
                SQL1,
            
            
                SQL2,
            
        
        where SQL3

完整例子




    


        update xxx
        
            
                SQL1,
            
            
                SQL2,
            
        
        where SQL3


    

    


        update xxx
        

            
                SQL1,
            
            
                SQL2,
            
        
        where SQL3


    

你可能感兴趣的:(mybatis,java,前端)