今天寫一個條件查詢的時候遇到了問題,也是好久沒寫了,最後終於解決了java
正確寫法sql
List<GmVipMember> selectByRealNameMemIdTelNum(@Param("realName") String realName,@Param("memId") String memId,@Param("telNum") String telNum)throws Exception;
複製代碼
錯誤寫法bash
List<GmVipMember> selectByRealNameMemIdTelNum(String realName,String memId,String telNum)throws Exception;
複製代碼
還有動態sql語句的寫法ui
<select id="selectByRealNameMemIdTelNum" resultType="com.gmos.vip.system.model.GmVipMember"
parameterType="java.lang.String">
select
*
from gm_vip_member
where
<if test="realName!=null and realName!=''">
real_name = #{realName,jdbcType=VARCHAR}
</if>
<if test="memId!=null and memId!=''">
and mem_id = #{memId,jdbcType=VARCHAR}
</if>
<if test="telNum!=null and telNum!=''">
and tel_num = #{telNum,jdbcType=VARCHAR}
</if>
</select>
複製代碼
<select id="selectByRealNameMemIdTelNum" resultType="com.gmos.vip.system.model.GmVipMember"
parameterType="java.lang.String">
select
*
from gm_vip_member
<where>
<if test="realName!=null and realName!=''">
and real_name = #{realName,jdbcType=VARCHAR}
</if>
<if test="memId!=null and memId!=''">
and mem_id = #{memId,jdbcType=VARCHAR}
</if>
<if test="telNum!=null and telNum!=''">
and tel_num = #{telNum,jdbcType=VARCHAR}
</if>
</where>
</select>
複製代碼