我正在尝试根据另外两个表(DMS_TEST_LOAD
和TDCE_NE
)更新表格(TDCE_NE_COMP
)。知道下面的查询有什么问题吗?我一直在UPDATE语句中得到无用的“语法错误”。来自Access的错误。提前谢谢。
UPDATE DMS_TEST_LOAD AS DMS
((INNER JOIN TDCE_NE_COMP AS COMP
ON COMP.[NAME] LIKE DMS.[Trunk Group Number (TGN)] AND COMP.[NE_COMP_TYPE_ID]=421)
INNER JOIN TDCE_NE AS NE ON NE.[ID]=COMP.[NE_ID] AND NE.[NAME]=DMS.[Office])
SET DMS.[Char Parm 1 (Trk Dir)] = COMP.[CHAR_PARM1];
答案 0 :(得分:1)
不太确定SQL系统MS访问使用的是什么。但你可能想尝试这个
UPDATE DMS
SET DMS.[Char Parm 1 (Trk Dir)] = COMP.[CHAR_PARM1]
FROM DMS_TEST_LOAD AS DMS
INNER JOIN TDCE_NE_COMP AS COMP
ON COMP.[NAME] LIKE DMS.[Trunk Group Number (TGN)]
AND COMP.[NE_COMP_TYPE_ID]=421
INNER JOIN TDCE_NE AS NE
ON NE.[ID]=COMP.[NE_ID] AND NE.[NAME]=DMS.[Office];
答案 1 :(得分:0)
在MS Access中,您必须确保在连接中正确使用括号。我相信你是在追求以下目标:
UPDATE DMS
SET DMS.[Char Parm 1 (Trk Dir)] = COMP.CHAR_PARM1
FROM (DMS_TEST_LOAD AS DMS
INNER JOIN TDCE_NE_COMP AS COMP
ON (COMP.NAME = DMS.[Trunk Group Number (TGN)]) AND (COMP.NE_COMP_TYPE_ID = 421))
INNER JOIN TDCE_NE AS NE
ON (NE.Name = DMS.Office) AND (COMP.NE_ID = NE.ID)
注意我删除了LIKE
并将其替换为=
。您没有使用任何通配符,因此它甚至不能用作LIKE
。如果您想使用LIKE
,您可能正在寻找以下内容:
COMP.NAME LIKE "*" & DMS.[Trunk Group Number (TGN)] & "*"
答案 2 :(得分:0)
这样的事情怎么样......
UPDATE DMS
SET [Char Parm 1 (Trk Dir)] = COMP.[CHAR_PARM1]
FROM DMS_TEST_LOAD DMS
INNER JOIN TDCE_NE_COMP AS COMP
ON COMP.[NAME] LIKE DMS.[Trunk Group Number (TGN)]
AND COMP.[NE_COMP_TYPE_ID]=421
INNER JOIN TDCE_NE AS NE
ON NE.[ID]=COMP.[NE_ID]
AND NE.[NAME]=DMS.[Office]
未经测试但重构为ANSI 92"标准" SQL
可以使用...
测试(实际上没有更新c)SELECT [Char Parm 1 (Trk Dir)], COMP.[CHAR_PARM1]
FROM DMS_TEST_LOAD DMS
INNER JOIN TDCE_NE_COMP AS COMP
ON COMP.[NAME] LIKE DMS.[Trunk Group Number (TGN)]
AND COMP.[NE_COMP_TYPE_ID]=421
INNER JOIN TDCE_NE AS NE
ON NE.[ID]=COMP.[NE_ID]
AND NE.[NAME]=DMS.[Office]