How to write Mybatis like query

Mybatis like query official documents there is no clear example to follow, a lot of searches on the Internet, are not correct.

 

Mybatis 3.2.6

After trying, three reliable and usable ways of writing are given:

 

select * from person where name  like "%"#{name}"%"

 

select * from person where name  like '%'||#{name}||'%'

 

select * from person where name  like '%${name}%'

 

After comparing the three writing methods, the first one belongs to precompiled SQL, and the latter two are not. Therefore, the first writing method is recommended.

This article is from the " Lava " blog, please be sure to keep this source http://lavasoft.blog.51cto.com/62575/1386870

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326610141&siteId=291194637