<select id="selectbykeyword" parametertype="string" resulttype="com.why.mybatis.entity.roleentity">
select
*
from
t_role
where
role_name like #{rolename}
or id like #{id}
or role_type like #{roletype}
</select>
执行出来的sql语句:
select
*
from
t_role
where
role_name like '%why%'
or id like '%why%'
or role_type like '%why%';
<select id="selectbykeyword" parametertype="string" resulttype="com.why.mybatis.entity.roleentity">
select
*
from
t_role
where
role_name like concat('%',#{keyword},'%')
or
id like concat('%',#{keyword},'%')
or
role_type like concat('%',#{keyword},'%')
</select>
<select id="selectbykeyword" parametertype="string" resulttype="com.why.mybatis.entity.roleentity">
<bind name="pattern" value="'%' + keyword + '%'" />
select
*
from
t_role
where
role_name like #{pattern}
or
id like #{pattern}
or
role_type like #{pattern}
</select>