Forum Moderators: open
*but!*
SELECT *
FROM EmploymentRecords AS er, Employees AS e, user AS u
WHERE u.idPerson = e.idPerson
AND er.idEmployee = e.idEmployee
AND u.idUser = 'lea.de.groot'
ORDER BY er.dtStarted DESC
works fine
and
SELECT *
FROM EmploymentRecords AS er
LEFT OUTER JOIN restaurants AS r ON r.idRestaurant = er.idRestaurant
works fine
(ER:
An EMPLOYEE will:
- have one USER record, continaing username and password, (1 - 1)and
- have an EMPLOYMENTRECORD for each time they are employed or change
restaurants (1 - many))
I am quite bemused by what could be causing this.
Anyone have any idea?
(Help!)
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 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.
[dev.mysql.com...]
Page down to see the compliance with SQL:2003 standard and how to rewrite your query accordingly. Scan for the word "precedence" on the page and you'll find your answer.