select * from a <where> <!-- 模糊查询 --> <if test="name !=null || name !=''"> and name like '%'||#{name}||'%' //name like '%${name}%' </if> <if test="age !=null || age!=''"> and name = #{age} </if> <if test="sex !=null and sex!=''"> and sex = #{sex} </if> </where>