第一種,直接傳參法
傳入參數 userName=%張%
<select id="findList1" resultType="com.pojo.User">
SELECT * from USER where username like #{userName}
</select>函數
第二種,CONCAT()函數
傳入參數 userName=張
<select id="findList1" resultType="com.pojo.User">
SELECT * from USER where username like concat('%',#{userName},'%')
</select>spa
第三種,bind( )函數
傳入參數 userName=張
<select id="findList1" resultType="com.pojo.User">
<bind name="userName" value="'%'+userName+'%'"></bind>
SELECT * from USER where username like #{userName}
</select>List
第四種,$和%結合使用select
傳入參數 userName=張
<select id="findList1" resultType="com.pojo.User">
SELECT * from USER where username like '%${userName}%'
</select>bind
第五種,#和%結合使用
傳入參數 userName=張
<select id="findList1" resultType="com.pojo.User">
SELECT * from USER where username like "%"#{userName}"%"
</select>co