Mybatis中SQL语句当传入参数有时为空有时为值的时候,报错及解决方法


<select id="getOilStaticListByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String">
        select
        <include refid="Base_Column_List"/>
        from oilstation
        <where>
        <if test="universalCode!=null and  universalCode!=''">
            and UniversalCode = #{universalCode}
        </if>
        </where>
 </select>

要把where改成标签,否则sql语句报错!!
SELECT COUNT(*) FROM
(SELECT
UniversalCode,
Address,
IsFacilityPay,
Location,
OUCode
FROM
oilstation
WHERE) tmp_count

你可能感兴趣的:(Mybatis中SQL语句当传入参数有时为空有时为值的时候,报错及解决方法)