the question about sql left join on? [closed]
This question is about SQL left joins. What, if anything, is the difference between the following two queries?
(1)
select * f开发者_如何学编程rom A
LEFT JOIN B
ON A.field = B.field
(2)
select * from A
LEFT JOIN B
ON B.field = A.field
I'd like to provide more content, but all I can say is: there is no difference, the order of the fields doesn't matter.
There is no difference; these are identical statements.
None at all. If you get different results for these queries, there's something fundamentally wrong with you DB technology...
Both statements will produce the same output
A LEFT JOIN
is based on the tables, not on the columns you are joining by.
In your case, the Table A is LEFT JOINED to Table B, the order of columns specified in the join do not affect the result in any way.
Now, if you changed the order of the tables, then you would expect to get a different result. A LEFT JOIN B
is not the same as B LEFT JOIN A
.
精彩评论