Forum Discussion
Update Query - 3 criteria
- Feb 06, 2025
Running the Select query on only the Copy table does not prove that the main table also has records with same values in the join fields.
Rather make a copy of the Update query, and switch to Select query.
Running the Select query on only the Copy table does not prove that the main table also has records with same values in the join fields.
Rather make a copy of the Update query, and switch to Select query.
- Tony2021Feb 06, 2025Iron Contributor
I have now figured it out. The update To criteria needs to be on the table you are grabbing the data FrOM but the update CRTERIA needs to be on the target table (as I initially thought but I was putting the update criteria on the other table. Little difficult to explain. All in all I had 3 colyumns but needed 6. I have never liked update queries when joining tables.
this works:
UPDATE Import_ExcelPC INNER JOIN Import_ExcelPC_Copy ON (Import_ExcelPC.[Invoice amount] = Import_ExcelPC_Copy.[Invoice amount]) AND (Import_ExcelPC.[Invoice No Stripped] = Import_ExcelPC_Copy.[Invoice No Stripped])
SET Import_ExcelPC.Notes = [Import_ExcelPC_Copy].[Notes], Import_ExcelPC.OKToPayYN = [Import_ExcelPC_Copy].[OKToPayYN], Import_ExcelPC.DABYN = [Import_ExcelPC_Copy].[DABYN]
WHERE (((Import_ExcelPC_Copy.Notes) Is Not Null)) OR (((Import_ExcelPC_Copy.OKToPayYN)<>0)) OR (((Import_ExcelPC_Copy.DABYN)<>0));
- Tony2021Feb 06, 2025Iron Contributor
Hi Tom, thank you for the response.
<Running the Select query on only the Copy table does not prove that the main table also has records with same values in the join fields.
I am not sure what you mean but the join is on [Invoice No Stripped] and [Invoice Amount]. There are many records on this join criteria. I am positive of this.
I need to make sure I am understanding what is the main table.
Here are 2 queries
0 Hits
UPDATE
Import_ExcelPC INNER JOIN Import_ExcelPC_Copy ON (Import_ExcelPC.[Invoice amount] = Import_ExcelPC_Copy.[Invoice amount]) AND (Import_ExcelPC.[Invoice No Stripped] = Import_ExcelPC_Copy.[Invoice No Stripped])
SET
Import_ExcelPC.Notes = [Import_ExcelPC_Copy].[Notes], Import_ExcelPC.OKToPayYN = [Import_ExcelPC_Copy].[OKToPayYN], Import_ExcelPC.DABYN = [Import_ExcelPC_Copy].[DABYN]
WHERE(((Import_ExcelPC.Notes) Is Not Null)) OR (((Import_ExcelPC.OKToPayYN)<>0)) OR (((Import_ExcelPC.DABYN)<>0));
198 hits in below sql but its backwards meaning the table being updated is Import_ExcelPC_Copy but it should be Import_ExcelPC since that is the table I want to update.
UPDATE
Import_ExcelPC INNER JOIN Import_ExcelPC_Copy ON (Import_ExcelPC.[Invoice No Stripped] = Import_ExcelPC_Copy.[Invoice No Stripped]) AND (Import_ExcelPC.[Invoice amount] = Import_ExcelPC_Copy.[Invoice amount])
SET
Import_ExcelPC_Copy.Notes = [Import_ExcelPC_Copy].[Notes], Import_ExcelPC_Copy.OKToPayYN = [Import_ExcelPC_Copy].[OKToPayYN], Import_ExcelPC_Copy.DABYN = [Import_ExcelPC_Copy].[DABYN]
WHERE(((Import_ExcelPC_Copy.Notes) Is Not Null)) OR (((Import_ExcelPC_Copy.OKToPayYN)<>0)) OR (((Import_ExcelPC_Copy.DABYN)<>0));
Let me know your thoughts.