#1054 - Unknown column - SQL Query Problem [duplicate]

自闭症网瘾萝莉.ら 提交于 2019-11-28 10:48:48

问题


Possible Duplicate:
Was: Not unique table :: Now: #1054 - Unknown column - can't understand why?

After having solved a previous issue with this query, i'm now stuck with getting this error:

1054 - Unknown column 'calendar_events.jobID ' in 'on clause'

I can't undertstand why... and the column defiantly exists! Is it something to do with the WHERE blah AND ... section of the query at the bottom?

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

Any help would be appreciated!

Cheers


回答1:


You should use `calendar_events`.`jobID` instead of `calendar_events.jobID`. 



回答2:


INNER JOIN and , (comma) are semantically equivalent in the absence of a join condition: both produce a Cartesian product between the specified tables (that is, each and every row in the first table is joined to each and every row in the second table).

However, the precedence of the comma operator is less than of INNER JOIN, CROSS JOIN, LEFT JOIN, and so on. If you mix comma joins with the other join types when there is a join condition, an error of the form Unknown column 'col_name' in 'on clause' may occur. Information about dealing with this problem is given later in this section.

From: http://dev.mysql.com/doc/refman/5.0/en/join.html

Hope this helps



来源:https://stackoverflow.com/questions/3021587/1054-unknown-column-sql-query-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!