当我们只能使用一个时,为什么我们需要左右连接. [英] Why do we need both Left and Right join when we can work with just one.

查看:70
本文介绍了当我们只能使用一个时,为什么我们需要左右连接.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我们在SQL中有联接.有可能我们可以使用Left联接来完成所有联接逻辑(需要右联接时可以交换表).
因此任何人都可以帮助我,为什么当我们所有的工作都可以通过左联接来完成时,为什么我们需要右联接呢?

谢谢

Hi,

We have joins in SQL.Its possible that we can do all our join logic with Left join(We can interchange the tables when there is a need of right join).
So can anyone help me out that why do we need a right join when all our work can be done by using a left join.

Thanks

推荐答案

我认为您会发现此讨论很有趣,它也可能回答您的问题.
http://blog.sqlauthority.com /2010/11/28/sql-server-challenge-puzzle-why-does-right-join-exists/ [
I think you''ll find this discussion interesting and it may answer your question as well.
http://blog.sqlauthority.com/2010/11/28/sql-server-challenge-puzzle-why-does-right-join-exists/[^]


如果您正在使用sql中的join并在单个查询中联接三个表,并使用左联接将两个表联接在一起,并且您希望第三表的所有记录都不能在第三个表中使用左联接,因此您必须在第3个表中使用右联接表.
if you are using join in sql and join three tables in single query and with 2 tables using left join and you want all records of third table then you can''t use left join with 3rd table, so you have to use right join with 3rd table.


这篇关于当我们只能使用一个时,为什么我们需要左右连接.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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