本文介绍了错误代码:1054.未知列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下SQL语句:
SELECT efforts.user_id, project_tasks.task_name, sum(hours)
FROM efforts, users, project_tasks
INNER JOIN PROJECT_TASKS pu ON efforts.project_task_id = pu.id
INNER JOIN USERS u ON efforts.users_id = u.id
WHERE project_tasks.project_id = '2';
当我运行它时,出现以下错误:
And when I run it I get the following error:
Error Code: 1054. Unknown column 'efforts.project_task_id' in 'on clause'
为什么会出现此错误?
Project_task_id属于工作量表
Project_task_id belongs to efforts table
已更新:
SELECT u.full_name, pu.task_name, hours
FROM efforts
INNER JOIN project_tasks pu ON efforts.project_task_id = pu.id
INNER JOIN users u ON efforts.user_id = u.id
GROUP BY user_id, task_name
推荐答案
您的语法错误,应该是:
Your syntax is wrong, it should be:
SELECT efforts.user_id, pu.task_name, sum(hours)
FROM efforts
INNER JOIN PROJECT_TASKS pu ON efforts.project_task_id = pu.id
INNER JOIN USERS u ON efforts.user_id = u.id
WHERE pu.project_id = '2';
这篇关于错误代码:1054.未知列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!