SELECT*FROM
user
WHERE<if test='null!= name and ""!= name and "null"!= name'>
name LIKECONCAT(CONCAT('%',#{name},'%'))</if>
或
SELECT*FROM
user
WHERE
name LIKE'%'|| #{name}||'%'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
SQL Server
SELECT*FROM
user
WHERE
name LIKE'%'+#{name}+'%'
1
2
3
4
5
6
MySQL
SELECT*FROM
user
WHERE
name LIKECONCAT('%',#{name},'%')
1
2
3
4
5
6
DB2
SELECT*FROM
user
WHERE
name LIKECONCAT('%',#{name},'%')
或
SELECT*FROM
user
WHERE
name LIKE'%'||#{name}||'%'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
通用
SELECT*FROM
user
WHERE1=1<if test='name !=null and name !=""'><bind name="pattern" value="'%' + name + '%'"/>AND name LIKE #{pattern}</if>