SQL multiple join statement

后端 未结 3 2120
一整个雨季
一整个雨季 2020-11-22 09:08

When I had only one inner join in my SQL statement, it worked perfectly. I tried joining a second table, and now I am getting an error that says there is a syntax error (mis

3条回答
  •  隐瞒了意图╮
    2020-11-22 09:55

    For multi-table joins, you have to nest the extra joins in brackets:

    SELECT ...
    FROM ((origintable
    JOIN jointable1 ON ...)
    JOIN jointable2 ON ...)
    JOIN jointable3 ON ...
    

    basically, for every extra table you join past the first, you need a bracket before the original 'FROM' table, and a closing bracket on the matching JOIN 'on' clause.

提交回复
热议问题