SpringBoot整合Mybatis-Plus 实战之动态SQL,Mybatis最拿得出手的功能之一
MyBatis的动态SQL是最令人喜欢的功能 在了解 动态SQL之前,你首先得知道一个表达式 OGNL,这个是基础! 面试常问问题 : Mybatis 中$与#的区别? #是将传入的值当做字符串的形式,select id,name,age from test where id =#{id}, 当把id值传入到后台的时候,就相当于 select id,name,age from test where id =‘1’. " "是将传入的数据直接显示生成sql语句,selectid,name,agefromtestwhereid="是将传入的数据直接显示生成sql语句,select id,name,age from test where id = " 是 将 传 入 的 数 据 直 接 显 示 生 成 s q l 语 句 , s e l e c t i d , n a m e , a g e f r o m t e s t w h e r e i d = {id}, 当把id值1,传入到后台的时候,就相当于 select id,name,age from test where id = 1. 使用#可以很大程度上防止sql注入。(语句的拼接) if 标签 mapper select from test where 1=1 and username like concat('%', #