根据报错信息和给出的SQL语句,可以看出问题出现在第7行的左括号"("之前。在这个位置上,可能需要添加一个WHERE子句来分隔OR条件。

修改后的SQL语句如下:

<select id="export" resultType="com.citicmetal.customer.vo.CustomerInfoVO">
    SELECT
    ci.customer_id,
    ci.customer_name,
    ci.cbmm_cgs_name,
    ci.customer_type,
    ci.update_time,
    AVG(cs.score) averageScore
    FROM
    customer_management.cm_customer_info ci
    LEFT JOIN cm_customer_evaluate cs
    ON ci.customer_id = cs.customer_id
    <where>
        ci.del_flag = '0'
        <if test="query.keyword != null and query.keyword != ''">
            <bind name="keywordLike" value="'%'+query.keyword+'%'"/>
            AND (ci.customer_id LIKE #{keywordLike}
            OR ci.customer_name LIKE #{keywordLike}
            OR ci.cbmm_cgs_name LIKE #{keywordLike}
            OR ci.customer_type LIKE #{keywordLike}
            OR ci.update_time LIKE #{keywordLike})
        </if>
        <if test="query.customerType != null and query.customerType != ''">
            AND ci.customer_type = #{query.customerType}
        </if>
        AND (ci.user_id = #{query.userId} or ci.user_id is null)
        GROUP BY ci.customer_id
    </where>
</select>

在修改后的SQL语句中,我在第10行的第一个OR条件之前添加了一个左括号"(",并在第14行的最后一个OR条件之后添加了一个右括号")",以确保每个OR条件都被正确分组。请根据您的具体需求进行调整和修改

Caused by combaomidoumybatispluscoreexceptionsMybatisPlusException Failed to process Error SQL SELECT		cicustomer_id		cicustomer_name		cicbmm_cgs_name		cicustomer_type		ciupdate_time		AVGcsscore avera

原文地址: http://www.cveoy.top/t/topic/iDdR 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录