Answer the question
In order to leave comments, you need to log in
Where can there be an error in the SQL query?
select
sum(h.area),
sum(s.area)
from
table1 , table2
left join table1 h on table1.id = h.id
left join table2 s on table2.id = s.id
Answer the question
In order to leave comments, you need to log in
The reason is very simple. Formally, comma-style join is an alias for CROSS JOIN. But there is a catch - the priority of comma-style join is lower than the priority of explicit join. And the data source expression, if you arrange the brackets in accordance with the priority, you get this:
from
table1 , ( table2
left join table1 h on table1.id = h.id
left join table2 s on table2.id = s.id )
FROM table1
CROSS JOIN table2
LEFT JOIN table1 h ON table1.id = h.id
LEFT JOIN table2 s ON table2.id = s.id
FROM (table1 , table2)
LEFT JOIN table1 h ON table1.id = h.id
LEFT JOIN table2 s ON table2.id = s.id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question