2

Does the ANSI Standard find the following SQL sinppet syntactically correct? I am interested specifically in the last line:

SELECT name, dept_name
FROM employee JOIN department
     ON employee.dept_id = department.dept_id
     JOIN payroll ON payroll_type = 1;
2
  • But that is effectively a "cross join", since you have not spelled out how payroll relates to any of the other tables.
    – Rick James
    Jul 31, 2019 at 23:50
  • That is part of the problem as it turns out - no columns are retrieved from this table and removing the filter does not change the result set.
    – tale852150
    Jul 31, 2019 at 23:55

1 Answer 1

2

Yes, it is syntactically correct.

The ON clause can be any boolean expression - i.e. as long as it results in a boolean value (TRUE, FALSE, UNKNOWN).


Note that you have 3 tables that are visible in that ON clause: employee, department and payroll. You'll get an error if payroll_type is a column in more than one of them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.