SQL中的外部联接的目的(或用例)是什么? [英] What is the purpose (or use case) for an outer join in SQL?

查看:93
本文介绍了SQL中的外部联接的目的(或用例)是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

外部联接是否仅由开发人员用于分析?对于要为什么要在两个或多个表中包含不相关或与您的选择条件不匹配"的数据,我很难找到用例.

Is an outer join only used for analysis by the developer? I'm having trouble finding a use case for why you would want to include data in two or more tables that is unrelated or does not "match" your select criteria.

推荐答案

一个用例示例是生成一个报告,该报告显示所有客户及其购买的商品.也就是说,甚至向没有购买任何东西的顾客展示.如果您将客户和购买进行普通连接,则报告将仅显示那些至少购买了一次的客户.

An example use case would be to produce a report that shows ALL customers and their purchases. That is, show even customers who have not purchased anything. If you do an ordinary join of customers and purchases, the report would show only those customers with at least one purchase.

这篇关于SQL中的外部联接的目的(或用例)是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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