如何在sqlserver 2005中进行完全外连接?

时间:2021-09-26 16:28:55

How can you do a full outer join in sqlserver 2005?

如何在sqlserver 2005中进行完全外连接?

Seems like there is full outer join in sqlserver 2008 but I need to do this in sqlserver 2005.

似乎sqlserver 2008中有完全外连接,但我需要在sqlserver 2005中执行此操作。

In other words, I am merging two views based on the ACCTNUM col in both views (The views show aggregates so there is at most one ACCTNUM record in each view for each account) and I would like every record in each table to show up, even when there is no match in the other (ie, full outer join).

换句话说,我在两个视图中基于ACCTNUM col合并了两个视图(视图显示聚合,因此每个视图的每个视图中最多只有一个ACCTNUM记录),我希望每个表中的每条记录都显示出来,即使在另一个中没有匹配(即完全外连接)。

5 个解决方案

#1


SQL Server 2005 supports full joins:

SQL Server 2005支持完全连接:

In fact, I think FULL JOIN works at least as far back SQL Server 7.

事实上,我认为FULL JOIN至少可以用于SQL Server 7。

#2


This will work in SQL 2005

这将在SQL 2005中有效

Select
    tableA.Column,
    tableA.AnotherColumn,
    tableB.Column
From
    tableA
Full Outer Join
    tableB On tableA.Id = tableB.Id

Note you can use Full Join or Full Outer Join, it doesnt make a difference.

请注意,您可以使用完全加入或完全外部加入,它没有什么区别。

#3


Full outer joins should be supported by SQL Server 2005 - what makes you think they aren't?

SQL Server 2005应该支持完全外连接 - 是什么让你认为它们不是?

#4


Note that if you are using Access to connect to a DB, you can't use full outer join, since Access does not support it.

请注意,如果使用Access连接到数据库,则无法使用完全外连接,因为Access不支持它。

#5


SELECT A.*, B.* FROM TABLE1 A FULL JOIN TABLE2 B ON A.Id = B.TableAID

#1


SQL Server 2005 supports full joins:

SQL Server 2005支持完全连接:

In fact, I think FULL JOIN works at least as far back SQL Server 7.

事实上,我认为FULL JOIN至少可以用于SQL Server 7。

#2


This will work in SQL 2005

这将在SQL 2005中有效

Select
    tableA.Column,
    tableA.AnotherColumn,
    tableB.Column
From
    tableA
Full Outer Join
    tableB On tableA.Id = tableB.Id

Note you can use Full Join or Full Outer Join, it doesnt make a difference.

请注意,您可以使用完全加入或完全外部加入,它没有什么区别。

#3


Full outer joins should be supported by SQL Server 2005 - what makes you think they aren't?

SQL Server 2005应该支持完全外连接 - 是什么让你认为它们不是?

#4


Note that if you are using Access to connect to a DB, you can't use full outer join, since Access does not support it.

请注意,如果使用Access连接到数据库,则无法使用完全外连接,因为Access不支持它。

#5


SELECT A.*, B.* FROM TABLE1 A FULL JOIN TABLE2 B ON A.Id = B.TableAID