Parameter index out of range (2 > number of parameters, which is 1).
Parameter index out of range (1 > number of parameters, which is 0).
//上面两个报错或者数字换成别的,都是属于越界。
把mysql中的 #改为$就ok了
<select id="getEncounterAngelPage" resultType="User">
SELECT
<include refid="userColumns"/>
<if test="lng != null and lng != '' and lat != null and lat != ''">
,CEILING(SQRT(POWER(a.lng-${lng},2)+POWER(a.lat-${lat},2))*100000) AS distance
</if>
FROM sys_user a
<include refid="userJoins"/>
<if test="role != null and role.id != null and role.id != ''">
JOIN sys_user_role ur ON ur.user_id = a.id AND ur.role_id = ${role.id}
</if>
<where>
a.del_flag = #{DEL_FLAG_NORMAL}
AND (a.user_type = '1'
OR a.user_type = '2')
<if test="vcEncounterSet != null">
<if test="vcEncounterSet.ranges != null and vcEncounterSet.ranges != '' and vcEncounterSet.ranges == 2
and user != null and user != null and user.loginProvince != ''">
AND a.loginProvince LIKE CONCAT('%', #{user.loginProvince}, '%')
</if>
<if test="vcEncounterSet.ranges != null and vcEncounterSet.ranges != '' and vcEncounterSet.ranges == 3
and user != null and user != null and user.loginAddress != ''">
AND a.loginAddress LIKE CONCAT('%', #{user.loginAddress}, '%')
</if>
<if test="vcEncounterSet.identity != null and vcEncounterSet.identity != '' ">
<if test="vcEncounterSet.identity == 1">
AND (a.position ='0' OR
a.position = '1' OR
a.position = '2' OR
a.position= '3' )
</if>
<if test="vcEncounterSet.identity == 2">
AND (a.position ='0' OR
a.position = '1' OR
a.position = '2' )
</if>
<if test="vcEncounterSet.identity == 3">
AND (a.position ='0' OR
a.position = '1' )
</if>
</if>
<if test="vcEncounterSet.industry != null and vcEncounterSet.industry != '' and vcEncounterSet.industry == 1
and user != null and user != null and user.industryId != ''">
AND a.industry_id = ${user.industryId}
</if>
<if test="vcEncounterSet.sex != null and vcEncounterSet.sex != '' and vcEncounterSet.sex == 0">
AND a.sex = '0'
</if>
<if test="vcEncounterSet.sex != null and vcEncounterSet.sex != '' and vcEncounterSet.sex == 1">
AND a.sex = '1'
</if>
</if>
</where>
<choose>
<when test="lng != null and lng != '' and lat != null and lat != '' and page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy} , distance ASC
</when>
<otherwise>
ORDER BY vistors DESC
</otherwise>
</choose>
</select>