My Batis mapper.xml中 动态SQL中使用trim标签 if end的场景

trim标签有点类似于replace效果。

 trim 属性

                prefix:前缀覆盖并增加其内容

                suffix:后缀覆盖并增加其内容

                prefixOverrides:前缀判断的条件

                suffixOverrides:后缀判断的条件

 


 
        UPDATE test
       
        
         name = #{name},
        

        
         phone = #{phone},
        

        
         address = #{address},
        

      
 
        WHERE
         id = #{id}
 

输出sql

update test set name = #{name}, phone = #{phone}, address = #{address}   WHERE
         id = #{id}

 

 

 

输出sql   select * from user  WHERE user_id != #{userId}  and phone = #{phone} and state!='X'  

转载于:https://www.cnblogs.com/welcometowyy/p/5053495.html

你可能感兴趣的:(My Batis mapper.xml中 动态SQL中使用trim标签 if end的场景)