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

发布了60 篇原创文章 · 获赞 16 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_44142032/article/details/105231606