#1054 - Unknown column - SQL Query Problem [duplic

2019-01-28 23:57发布

问题:

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