MyBatis之简单模糊查询@多条件模糊查询
一个简单的查询案例
<select id="queryPage" parameterType="java.util.Map" resultType="com.summersoft.ts.common.dto.CommonConfigDto">
SELECT
**需要从表中查出的字段**
username userName,
password passWord
FROM yy_common_config mt
<include refid="sql_all"/>
</select>
<sql id="sql_all">
<where>
<if test="nameName != null"> AND mt.`name` LIKE CONCAT(CONCAT('%',#{nameName }),'%')</if>
</where>
</sql>
**多条件模糊查询的话 继续and就好了**
<sql id="sql_all">
<where>
<if test="nameName != null"> AND mt.`username ` LIKE CONCAT(CONCAT('%',#{nameName }),'%')</if>
<if test="passWord!= null"> AND mt.`password` LIKE CONCAT(CONCAT('%',#{passWord}),'%')</if>
</where>
</sql>