在LEFT JOIN之后填补缺失值的最佳方法? [英] Optimal way to fill in missing values after a LEFT JOIN?

查看:2484
本文介绍了在LEFT JOIN之后填补缺失值的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将简化我的问题,使核心问题清楚:我有一个查询 TableA INNER JOIN TableB LEFT JOIN TableC

I will simplify my problem to make the core issue clear: I have a query that does TableA INNER JOIN TableB LEFT JOIN TableC.

左连接的结果是在结果集中,两列在某些行中可能具有NULL值。为了填写缺失的值,我必须循环查询结果集,并查询另一个数据库,因此首先不能加入

The result of the left join is that in the result set, two of the columns might have NULL values in some rows. To fill in the missing values I have to loop over the result set and query another database that has the data (so it is not possible to join in the first place).

我的问题是:当我们需要填写左连接后的结果集的空值时,是否有标准/优化的方法?

My question is: Is there a standard/optimised approach when we need to fill nulls of a result set after a left join?

推荐答案

要填写缺少的值,我必须循环结果集并查询具有数据的另一个数据库(因此首先不可能加入)。

"To fill in the missing values I have to loop over the result set and query another database that has the data (so it is not possible to join in the first place)."

考虑一个不同的解决方案,然后循环填写数据。

Consider a different solution then looping to fill in data.

1.同一服务器上的另一个数据库= =容易只需使用db.schema限定名称加入。

1.Another database on the same server==easy. Just join using db.schema qualified names.


  1. 另一台服务器上的另一个数据库,仍然可能取决于您的网络拓扑。然后加入使用server.db.schema限定名称。

  1. Another database on a another server, still possibly depending on you network topography. Then join using server.db.schema qualified names.

如果您经常需要,请考虑复制所需的数据。

Consider replicating the data you need if you regularly need to do this.

这篇关于在LEFT JOIN之后填补缺失值的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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