哪个更好..左外部联接还是右外部联接? [英] Which is better.. left outer join or right outer join?

查看:94
本文介绍了哪个更好..左外部联接还是右外部联接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过这两种方式我们都可以得到相同的结果.

We can get the same result in both these ways..

Table_1 LEFT OUTER JOIN Table_2

Table_2 RIGHT OUTER JOIN Table_1

如果我们可以得到相同的结果,为什么要使用正确的外部联接?哪个更好?

If we can get the same result why to use right outer join ? Which one is better ?

推荐答案

正如其他人指出的那样,LEFT OUTER JOINRIGHT OUTER JOIN已经完全相同,但其参数相反.您的问题就像问写a < b还是b > a更好.它们是相同的-只是一个偏好问题.

As others have pointed out already LEFT OUTER JOIN and RIGHT OUTER JOIN are exactly the same operation, except with their arguments reversed. Your question is like asking whether it is better to write a < b or b > a. They're the same - it's just a matter of preference.

话虽如此,我发现大多数人对LEFT JOIN更为熟悉,并在他们的SQL中一致地使用它.有些人甚至发现在查询中间突然出现RIGHT JOIN时很难阅读,这使他们不得不停下来想一想这意味着什么.因此,我建议给定两个选项之间的均等选择,建议使用LEFT JOIN.保持一致将使其他开发人员更容易理解您的SQL.

Having said that, I find that most people are more familiar with LEFT JOIN and use it consistently in their SQL. Some people even find it quite difficult to read if there is suddenly a RIGHT JOIN in the middle of a query, and it causes them to have to stop and think what it means. So I'd suggest that given an equal choice between the two options, prefer to use LEFT JOIN. Being consistent will make it easier for other developers to understand your SQL.

这篇关于哪个更好..左外部联接还是右外部联接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆