是:不是唯一的表格::现在:#1054-未知列-无法理解为什么? [英] Was: Not unique table :: Now: #1054 - Unknown column - can't understand why?

查看:102
本文介绍了是:不是唯一的表格::现在:#1054-未知列-无法理解为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在MySQL中将某些表连接在一起,但似乎收到一条错误消息:#1066-不是唯一的表/别名:'calendar_jobs'

I'm trying to join some tables together in MySQL, but I seem to get an error saying: #1066 - Not unique table/alias: 'calendar_jobs'

我真的希望它从作业表中选择cal_events,2个用户位以及目标col的所有内容,但是如果没有任何作业,则变为"null".正确的加入似乎很合适,但行不通!谁能帮忙!?

I really want it to select everything from the cal_events, the 2 user bits and just the destination col from the jobs table, but become "null" if there arn't any job. A right join seemed to fit the bill but doesn't work! Can anyone help!?

更新:

感谢上一个查询的帮助,我现在可以解决这个问题:

Thanks for the help on the previous query, I'm now up to this:

SELECT calendar_events.* , calendar_users.doctorOrNurse, calendar_users.passportName, calendar_jobs.destination
FROM `calendar_events` , `calendar_users`
RIGHT JOIN calendar_jobs ON calendar_events.jobID = calendar_jobs.jobID
WHERE `start` >= 0
AND calendar_users.userID = calendar_events.userID;

但是现在出现一条错误消息:#1054-'on子句'中的未知列'calendar_events.jobID'

But am now getting an error saying: #1054 - Unknown column 'calendar_events.jobID' in 'on clause'

这次是什么!?

再次感谢!

推荐答案

您不应在FROM子句中使用calendar_jobs,因为您已经在JOIN中指定了它.试试这个:

You shouldn't use calendar_jobs in the FROM clause, because you've already specified it in the JOIN. Try this:

SELECT calendar_events.* , calendar_users.doctorOrNurse, calendar_users.passportName, calendar_jobs.destination
FROM `calendar_events` , `calendar_users`
RIGHT JOIN calendar_jobs ON calendar_events.jobID = calendar_jobs.jobID
WHERE `start` >=0
AND calendar_users.userID = calendar_events.userID


更新答案:


Answer for update:

所有证据似乎都表明该表中不存在该列:).

All evidence seems to indicate that the column doesn't exist in that table :).

尝试一下:

SELECT calendar_events.* , calendar_users.doctorOrNurse, calendar_users.passportName, calendar_jobs.destination
FROM `calendar_users`, `calendar_events`
RIGHT JOIN calendar_jobs ON calendar_events.jobID = calendar_jobs.jobID
WHERE `start` >=0
AND calendar_users.userID = calendar_events.userID

由于您将事件与作业结合在一起,因此FROM中的表顺序已切换.

The order of the tables in the FROM has been switched, because you join events with jobs.

这篇关于是:不是唯一的表格::现在:#1054-未知列-无法理解为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆