简体   繁体   中英

Syntax error in Access SQL query inner join

I have written the following query in MS Access SQL:

UPDATE [B-K Data]
SET [Supplier 1] = [PNTestImport].[MFR], [Supplier 1 order no] = [PNTestImport].[MFR_PN]
FROM [PNTestImport]
INNER JOIN [BK-Analogic-PN-CDB2006-import] on [B-K Data].[B-K no] = [BK-Analogic-PN-CDB2006-import].[BK PN]
INNER JOIN  [PNTestImport] on  [PNTestImport].[ITEM_NUMBER] = [BK-Analogic-PN-CDB2006-import].[Analogic PN];

I get a syntax error when I try to run the query, but no identification of where the problem lies.

When Googling the error, I found other with similar problem but no answer that works. What am I doing wrong here?

There's no FROM in an Access UPDATE clause. Tables are specified directly after UPDATE :

UPDATE [B-K Data]
INNER JOIN [BK-Analogic-PN-CDB2006-import] on [B-K Data].[B-K no] = [BK-Analogic-PN-CDB2006-import].[BK PN]
INNER JOIN  [PNTestImport] on  [PNTestImport].[ITEM_NUMBER] = [BK-Analogic-PN-CDB2006-import].[Analogic PN]
SET [Supplier 1] = [PNTestImport].[MFR], [Supplier 1 order no] = [PNTestImport].[MFR_PN]

Note that this also means all tables are editable in a single UPDATE clause, and all tables must be writable. There also cannot be ambiguity through joins, which can lead to problems with many-many matches.

In ms access you need () parentheses ro the form clause with join around the

UPDATE [B-K Data]
SET [Supplier 1] = [PNTestImport].[MFR], [Supplier 1 order no] = [PNTestImport].[MFR_PN]
FROM (( [PNTestImport]
INNER JOIN [BK-Analogic-PN-CDB2006-import] on 
       [B-K Data].[B-K no] = [BK-Analogic-PN-CDB2006-import].[BK PN])
INNER JOIN  [PNTestImport] on 
       [PNTestImport].[ITEM_NUMBER] = [BK-Analogic-PN-CDB2006-import].[Analogic PN]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM