今天写一个条件查询的时候遇到了问题,也是好久没写了,最后终于解决了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>
复制代码