0

在 tSQL 中编写自联接时,我可以避免重复的列名,因此:

SELECT FirstEvent.Title AS FirstTitle, SecondEvent.Title AS FirstTitle
FROM ContiguatedEvents AS FirstEvent
LEFT OUTER JOIN ContiguatedEvents AS SecondEvent
ON  FirstEvent.logID = SecondEvent.logID

假设我想从自连接中选择所有列,例如进入一个视图。然后我如何区分列名而不在连接语句中写出每一个。即有什么我可以这样写的(ish)

SELECT FirstEvent.* AS ???, SecondEvent.* AS ???
FROM ContiguatedEvents AS FirstEvent
LEFT OUTER JOIN ContiguatedEvents AS SecondEvent
ON  FirstEvent.logID = SecondEvent.logID
4

1 回答 1

1

没有办法自动为多列引入别名,您只需要手动完成。

快速将所有列名放入查询中的一个方便提示(在管理工作室中)是将Columns文件夹从对象资源管理器拖到查询窗口中。它为您提供所有列名。

于 2013-04-26T07:02:12.953 回答