动态sql(where标签)
作者:互联网
动态sql(where标签)
where标签就是为sql加上where关键字,且会自动的多余的and、or关键字,当所有的条件都不成立的时候,where标签也不会生成
<select id="getEmp" resultType="com.simple.simple1.Emp">
select * from t_user where
<if test="username!= null and username != ''">
username = #{username}
</if>
<if test="password!= null and password != ''">
and password = #{password}
</if>
<if test="age!= null and age != ''">
and age = #{age}
</if>
<if test="sex!= null and sex != ''">
and sex = #{sex}
</if>
<if test="email!= null and email != ''">
and email = #{email}
</if>
</select>
标签:username,标签,sex,sql,where,email 来源: https://www.cnblogs.com/new228666/p/16418447.html