1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| <select id="selectEmployeeByConditionByTrim" resultType="com.atguigu.mybatis.entity.Employee"> select emp_id,emp_name,emp_age,emp_salary,emp_gender from t_emp <trim prefix="where" suffixOverrides="and|or"> <if test="empName != null"> emp_name=#{empName} and </if> <if test="empSalary > 3000"> emp_salary>#{empSalary} and </if> <if test="empAge <= 20"> emp_age=#{empAge} or </if> <if test="empGender=='male'"> emp_gender=#{empGender} </if> </trim> </select>
|