MyBatis中Like语句使用总结

原生写法

eg:

select * from user where username like '%${value}%'

注意: 
    ${value}里面必须要写value,不然会报错

oracle数据库:

SELECT *  FROM  user  WHERE  name like CONCAT('%',#{name},'%')  

或 :

SELECT  *  FROM  user  WHERE  name like '%'||#{name}||'%'  

SQLServer数据库:

SELECT  *  FROM  user  WHERE  name like '%'+#{name}+'%'  

mysql数据库:

SELECT  *  FROM  user  WHERE  name like CONCAT('%',#{name},'%')  

DB2数据库:

SELECT  *  FROM  user  WHERE  name like CONCAT('%',#{name},'%')  

SELECT  *  FROM  user  WHERE  name like '%'||#{name}||'%'  
上一篇:Python 正则介绍


下一篇:「 从0到1学习微服务SpringCloud 」02 Eureka服务注册与发现