旧式 JOIN 语法在 T-SQL 中是啥意思?
Posted
技术标签:
【中文标题】旧式 JOIN 语法在 T-SQL 中是啥意思?【英文标题】:What does the old-style JOIN syntax mean in T-SQL?旧式 JOIN 语法在 T-SQL 中是什么意思? 【发布时间】:2016-03-02 09:04:50 【问题描述】:我需要编辑旧式 T-SQL 代码。
=*
是什么意思?
*=
是什么意思?
我认为,它们是 JOIN,但我不知道它们每个是什么 JOIN 类型。
【问题讨论】:
那些是外连接 它们之间有什么区别? 一个是左连接,另一个是右连接。详见手册msdn.microsoft.com/en-us/library/… 【参考方案1】:我找到答案了!
-- Example 1: Deprecated syntax for an inner join
SELECT [T2].[c3], [T1].[c3]
FROM [dbo].[Table2] T2, [dbo].[Table1] T1
WHERE [T1].[ID] = [T2].[ID]
-- Example 2: Current syntax for an inner join
SELECT [T2].[c3], [T1].[c3]
FROM [dbo].[Table2] AS T2
INNER JOIN [dbo].[Table1] as T1
ON [T2].[ID] = [T2].[ID]
-- Example 3: Deprecated syntax for a left outer join
SELECT [T2].[c3], [T1].[c3]
FROM [dbo].[Table2] T2, [dbo].[Table1] T1
WHERE [T1].[ID] *= [T2].[ID]
-- Example 4: Fixed syntax for a left outer join
SELECT [T2].[c3], [T1].[c3]
FROM [dbo].[Table2] AS T2
LEFT OUTER JOIN [dbo].[Table1] as T1
ON [T2].[ID] = [T2].[ID]
-- Example 5: Deprecated syntax for a right outer join
SELECT [T2].[c3], [T1].[c3]
FROM [dbo].[Table2] T2, [dbo].[Table1] T1
WHERE [T1].[ID] =* [T2].[ID]
-- Example 6: Fixed syntax for a right outer join
SELECT [T2].[c3], [T1].[c3]
FROM [dbo].[Table2] AS T2
RIGHT OUTER JOIN [dbo].[Table1] as T1
ON [T2].[ID] = [T2].[ID]
https://msdn.microsoft.com/en-us/library/dd172122(v=vs.100).aspx
【讨论】:
这里有明显的错别字:[T2].[ID] = [T2].[ID]
。 MSDN 并不完美。以上是关于旧式 JOIN 语法在 T-SQL 中是啥意思?的主要内容,如果未能解决你的问题,请参考以下文章