在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
假设我想从自联接中选择所有列,例如选择视图。然后,我如何区分列名而不在join语句中写出每个列名。即有什么我可以写这样的(ish)
SELECT FirstEvent.* AS ???, SecondEvent.* AS ???
FROM ContiguatedEvents AS FirstEvent
LEFT OUTER JOIN ContiguatedEvents AS SecondEvent
ON FirstEvent.logID = SecondEvent.logID
答案 0 :(得分:1)
无法为多列自动引入别名,您只需手动执行即可。
快速将所有列名称放入查询(管理工作室)中的一个方便提示是将Columns
文件夹从对象资源管理器拖到查询窗口中。它为您提供了所有列名称。