什么是PostgreSQL中的LEFT JOIN

编程入门 行业动态 更新时间:2024-10-25 20:24:25
本文介绍了什么是PostgreSQL中的LEFT JOIN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经看到使用 LEFT JOIN 而不是 INNER 或左外。

I've seen a query using a LEFT JOIN as opposed to an INNER or LEFT OUTER.

什么是左联接?

推荐答案

其中内部联接仅返回在两个表中都匹配的条目,而 left join 从第一个表中获取所有条目,并从第二个表中匹配所有条目。 右连接与左连接(即:全部来自第二张表)相反。

Where an inner join returns only entries that match in both tables, a left join takes all the entries from first table and any that match in the second table. A right join is the reverse of a left join (ie: all from the second table)

因此,如果TableA是

So if TableA is

A B 1 a 2 b 3 c

和TableB是

A B 1 d 2 e

然后从TableA上的TableA内部联接TableB中选择* = TableB.A 返回

1 a 1 d 2 b 2 e

并且 Select * from TableA左联接TableA.A = TableB.A上的TableB

And Select * from TableA left join TableB on TableA.A = TableB.A returns

1 a 1 d 2 b 2 e 3 c null null

更多推荐

什么是PostgreSQL中的LEFT JOIN

本文发布于:2023-10-27 03:37:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1532201.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:PostgreSQL   LEFT   JOIN

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!