SQL 传统加入
SQL Legacy Joins
我正在查看一些较旧的 SQL 代码,我想知道将此批处理转换为当前 SQL 语法的正确方法是什么。感谢您的帮助。
If @Type = 'Edit'
Begin
If @Area = 'Box'
Declare CursorInv Cursor For
Select Retention_Code,
Company_Id,
Department_Id,
Group_Id,
Section_Id,
Locator_Id,
Location_Current,
Location_Home,
Box_User_Defined1.Udf_Code User_Defined1,
Box_User_Defined2.Udf_Code User_Defined2,
Box_User_Defined3.Udf_Code User_Defined3
From Box, Box_User_Defined1, Box_User_Defined2, Box_User_Defined3
Where Box_Number = @KeyValue And
Box.User_Defined1 *= Box_User_Defined1.ID And
Box.User_Defined2 *= Box_User_Defined2.ID And
Box.User_Defined3 *= Box_User_Defined3.ID
*=
几乎加入了更新语法中的 LEFT JOIN
:
SELECT Retention_Code,
Company_Id,
Department_Id,
Group_Id,
Section_Id,
Locator_Id,
Location_Current,
Location_Home,
Box_User_Defined1.Udf_Code User_Defined1,
Box_User_Defined2.Udf_Code User_Defined2,
Box_User_Defined3.Udf_Code User_Defined3
FROM Box
LEFT JOIN Box_User_Defined1 ON Box.User_Defined1 = Box_User_Defined1.ID
LEFT JOIN Box_User_Defined2 ON Box.User_Defined2 = Box_User_Defined2.ID
LEFT JOIN Box_User_Defined3 ON Box.User_Defined3 = Box_User_Defined3.ID
WHERE Box_Number = @KeyValue
我正在查看一些较旧的 SQL 代码,我想知道将此批处理转换为当前 SQL 语法的正确方法是什么。感谢您的帮助。
If @Type = 'Edit'
Begin
If @Area = 'Box'
Declare CursorInv Cursor For
Select Retention_Code,
Company_Id,
Department_Id,
Group_Id,
Section_Id,
Locator_Id,
Location_Current,
Location_Home,
Box_User_Defined1.Udf_Code User_Defined1,
Box_User_Defined2.Udf_Code User_Defined2,
Box_User_Defined3.Udf_Code User_Defined3
From Box, Box_User_Defined1, Box_User_Defined2, Box_User_Defined3
Where Box_Number = @KeyValue And
Box.User_Defined1 *= Box_User_Defined1.ID And
Box.User_Defined2 *= Box_User_Defined2.ID And
Box.User_Defined3 *= Box_User_Defined3.ID
*=
几乎加入了更新语法中的 LEFT JOIN
:
SELECT Retention_Code,
Company_Id,
Department_Id,
Group_Id,
Section_Id,
Locator_Id,
Location_Current,
Location_Home,
Box_User_Defined1.Udf_Code User_Defined1,
Box_User_Defined2.Udf_Code User_Defined2,
Box_User_Defined3.Udf_Code User_Defined3
FROM Box
LEFT JOIN Box_User_Defined1 ON Box.User_Defined1 = Box_User_Defined1.ID
LEFT JOIN Box_User_Defined2 ON Box.User_Defined2 = Box_User_Defined2.ID
LEFT JOIN Box_User_Defined3 ON Box.User_Defined3 = Box_User_Defined3.ID
WHERE Box_Number = @KeyValue