开发者

the question about sql left join on? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜