I don't understand the FROM clause with ON in an unexpected place

I inherited the request. This is the product of some query designer. Request Form:

select stuff
    from a
        join b
        join c on b.k = c.k
        join d on c.j = d.j
        on a.l = d.l
            and a.m = d.m
        join e on a.n = e.n

I expect the join to be join t1 on t1.f = t0.flike the second, third and fourth lines with "join". I do not know how I should read this query with a table that does not have 'on' immediately after it, and then two times in a row.

But the server does not mind. It returns a dataset that serves us well, and now that we want to change the material we select. How does the server analyze this?

TIA

+4
source share
2 answers

You better understand the query with parentheses:

select stuff
from a join
     (b join
      c
      on b.k = c.k join
      d
      on c.j = d.j
     )
     on a.l = d.l and a.m = d.m join
     e
     on a.n = e.n

. , , , . , join on .

+3

, , SQL Server , .

select stuff
from a
    join 
    (
        b
        join c on b.k = c.k
        join d on c.j = d.j
    )
    on a.l = d.l and a.m = d.m
    join e on a.n = e.n

: " : b, c, d. e". ​​

, , . . , , .

, , .

select stuff
from b
join c on b.k = c.k   
join d on c.j = d.j
join a on a.l = d.l and a.m = d.m
join e on a.n = e.n
+1

All Articles