MyBatis中Like语句使用总结
原生写法:
select * from user where username like '%${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}||'%'