#1054 - Unknown column - SQL Query Problem [duplic

2019-01-29 00:18发布

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

2条回答
家丑人穷心不美
2楼-- · 2019-01-29 01:01

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

查看更多
Evening l夕情丶
3楼-- · 2019-01-29 01:02
You should use `calendar_events`.`jobID` instead of `calendar_events.jobID`. 
查看更多
登录 后发表回答