0

I have this SQL statement, I am getting a syntax error:

SELECT
  *
FROM
  user_table
  INNER JOIN (
    klass_table
    LEFT JOIN room_table
  )

Syntax error is vague, it says:

You have an error in your SQL syntax; it seems the error is around: ')' at line 8

Perhaps I am missing an ON clause?

4
  • 2
    Perhaps, what happened when you added one? Doesn’t really make sense to have a left join without one Commented Feb 16, 2019 at 7:03
  • Yeah it works when I add an ON clause to the LEFT JOIN. It doesn't look like I need an ON clause for INNER JOIN, tho. Commented Feb 16, 2019 at 7:27
  • Yes, their function is different so their requirements are also different. Commented Feb 16, 2019 at 7:36
  • 1
    You do need a join condition (specified with ON) for an inner join. Those parentheses are pretty much useless by the way: from user_table join klass_table on ... left join room_table on ... works just as well Commented Feb 16, 2019 at 7:38

1 Answer 1

1

You have not mentioned the columns on which you are doing the inner join.So basically you are missing the "ON" keyword for both the joins.

Sign up to request clarification or add additional context in comments.

2 Comments

Yeah the ON keyword only seems to be necessary for the LEFT JOIN, not necessary for the INNER JOIN
@rakim: the ON condition is needed for all joins except cross join

Your Answer

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