我有一张我用代码选择的表:代码 A
Select TDS, TL, IK
From (Select Sheet1.TOOLING_DATA_SHEET As TDS, Sheet1.CUTTING_TOOL As TL, ENT_ITEM_MASTER.ITEM_KEY As IK
From Sheet1
Inner Join ENT_ITEM_MASTER
On ENT_ITEM_MASTER.ITEM_CODE=Sheet1.CUTTING_TOOL And ENT_ITEM_MASTER.USER_LAST_MODIFIED Is Not Null) As A
输出:
TDS TL IK
TDS-1980D-10+OP10+S7 TL-000032 1
TDS-1980D-10+OP10+S7 TL-000019 34
TDS-2258-01+OP10+S4 TL-000016 53
TDS-2325PU+OP10+S1 TL-000036 7
TDS-1234-56-78 TL-000123 45
以及我用代码选择的另一个表:代码 B
Select ENT_LINK_OBJECTS.OBJ_NAME, ENT_ITEM_MASTER.ITEM_CODE, ENT_ITEM_MASTER.ITEM_KEY
From ENT_LINK_OBJECTS
Inner Join ENT_ITEM_MASTER
On ENT_ITEM_MASTER.ITEM_KEY=ENT_LINK_OBJECTS.ENTITY_KEY And ENT_ITEM_MASTER.USER_LAST_MODIFIED Is Not Null) As B
输出:
OBJ_NAME ITEM_CODE ITEM_KEY
TDS-1980D-10+OP10+S7 TL-000032 1
TDS-1980D-10+OP10+S7 TL-000019 34
TDS-2258-01+OP10+S4 TL-000032 28
TDS-2258-01+OP10+S4 TL-000016 53
TDS-2325PU+OP10+S1 TL-000036 7
TDS-2325PU+OP10+S1 TL-000009 9
我已经在工作代码中加入了表格,这给了我在表 A 中但不在表 B 中的所有内容。
我现在正在尝试右连接表,这将为我提供表 B 中不在表 A 中的所有内容。现在输出什么都没有。
Right Join的完整代码:
Select TDS, TL, IK
From (Select Sheet1.TOOLING_DATA_SHEET, Sheet1.CUTTING_TOOL, ENT_ITEM_MASTER.ITEM_KEY
From Sheet1
Inner Join ENT_ITEM_MASTER
On ENT_ITEM_MASTER.ITEM_CODE=Sheet1.CUTTING_TOOL And ENT_ITEM_MASTER.USER_LAST_MODIFIED Is Not Null) As A
Right Join (Select ENT_LINK_OBJECTS.OBJ_NAME As TDS, ENT_ITEM_MASTER.ITEM_CODE As TL, ENT_ITEM_MASTER.ITEM_KEY As IK
From ENT_LINK_OBJECTS
Inner Join ENT_ITEM_MASTER
On ENT_ITEM_MASTER.ITEM_KEY=ENT_LINK_OBJECTS.ENTITY_KEY And ENT_ITEM_MASTER.USER_LAST_MODIFIED Is Not Null) As B
On A.TOOLING_DATA_SHEET=B.TDS
Where A.TOOLING_DATA_SHEET is Null
电流输出:
TDS TL IK
期望的输出:(B中不在A中的所有内容)
TDS TL IK
TDS-2258-01+OP10+S4 TL-000032 28
TDS-2325PU+OP10+S1 TL-000009 9
如果有帮助,我可以为我的左连接添加我的工作代码。我还尝试切换选择区域,执行左连接,并更改 Null 语句以尝试左连接,这也没有提供任何输出。
编辑:
我的代码如何与左连接一起工作:
Select TDS, TL, IK
From (Select Sheet1.TOOLING_DATA_SHEET As TDS, Sheet1.CUTTING_TOOL As TL, ENT_ITEM_MASTER.ITEM_KEY As IK
From Sheet1
Inner Join ENT_ITEM_MASTER
On ENT_ITEM_MASTER.ITEM_CODE=Sheet1.CUTTING_TOOL And ENT_ITEM_MASTER.USER_LAST_MODIFIED Is Not Null) As A
Left Join (Select ENT_LINK_OBJECTS.OBJ_NAME, ENT_ITEM_MASTER.ITEM_CODE, ENT_ITEM_MASTER.ITEM_KEY
From ENT_LINK_OBJECTS
Inner Join ENT_ITEM_MASTER
On ENT_ITEM_MASTER.ITEM_KEY=ENT_LINK_OBJECTS.ENTITY_KEY And ENT_ITEM_MASTER.USER_LAST_MODIFIED Is Not Null) As B
On A.TDS=B.OBJ_NAME
Where B.OBJ_NAME is Null
输出:(A 中不属于 B 的所有内容)
TDS TL IK
TDS-1234-56-78 TL-000123 45