2015-11-28 46 views
2

我需要編輯舊式的T-SQL代碼。舊式JOIN語法在T-SQL中意味着什麼?

  • =*是什麼意思?

  • *=是什麼意思?

我想,他們是加入,但我不知道,什麼樣的加入類型是他們每個人。

+0

這些都是外部連接 –

+0

而這也正是他們的區別? –

+3

一個是左連接另一個是右連接。詳細信息請參閱手冊https://msdn.microsoft.com/en-us/library/aa259187%28v=sql.80%29.aspx#_where_clause –

回答

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

+0

這裏有明顯的拼寫錯誤:'[T2]。[ID] = [T2]。[ID]'。 MSDN並不完美。 –