SQL Error: Unknown column 'ci.user_id' in 'where clause' - 解决方法
Error querying database. Cause: java.sql.SQLSyntaxErrorException: Unknown column 'ci.user_id' in 'where clause' ### The error may exist in file [C:\project\zhongxin\CiticMetal-Backend\customer\customer-biz\target\classes\mapper\CustomerInfoMapper.xml] ### The error may involve defaultParameterMap ### The error occurred while setting parameters ### SQL: SELECT COUNT(*) FROM (SELECT ci.customer_id, ci.customer_name, ci.cbmm_cgs_name, ci.customer_type, ci.update_time FROM cm_customer_info ci WHERE ci.del_flag = '0' AND (ci.user_id = ? OR ci.user_id IS NULL) GROUP BY ci.customer_id) TOTAL ### Cause: java.sql.SQLSyntaxErrorException: Unknown column 'ci.user_id' in 'where clause' ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Unknown column 'ci.user_id' in 'where clause'
前端报错,
======= Sql Logger ====================== select count(*) from ( select ci.customer_id, ci.customer_name, ci.cbmm_cgs_name, ci.customer_type, ci.update_time from cm_customer_info ci where ci.del_flag = '0' and (ci.user_id = 1646326606744612866 or ci.user_id is null) group by ci.customer_id ) TOTAL ======= Sql Execute Time: 0ms ======= idea控制台没有报错但是sql执行0ms
这个sql在数据库执行查询没有问题可以出数据
,分析一下内容:根据报错信息,错误发生在查询语句的WHERE子句中,具体是在ci.user_id = ? OR ci.user_id IS NULL这个条件中,报错信息显示Unknown column 'ci.user_id' in 'where clause',意思是在cm_customer_info表中找不到user_id列。
可能的原因是数据库表结构发生了变化,cm_customer_info表中没有user_id列。解决方法是检查数据库表结构,确保表中存在user_id列,并且列名拼写正确。
另外,根据SQL语句可以看出,查询语句中使用了子查询,并且使用了GROUP BY语句。可能需要进一步检查数据库表结构和数据,确保查询语句的正确性。
原文地址: https://www.cveoy.top/t/topic/qho2 著作权归作者所有。请勿转载和采集!