Solved

Inner join and update statement in Access

Posted on 2009-05-11
2
502 Views
Last Modified: 2012-05-06

I saw below SQL statement in an Access project:
  db.Execute "UPDATE tableA INNER JOIN tableB" _
               & "ON tableA.NUMBER = tableB.Number_ASC" _
               & "Set tableA.field1 = tableB.field1
            ...

I don't have much experience in Access, could anyone explain this query? Is it a common practice in Access? BTW, I know inner join, but am just not used to the usage of the update statement here. Thanks.

 
0
Comment
Question by:heyday2004
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 400 total points
ID: 24352281
that UPDATE does a update of tableA, if there are matching rows in tableB, based on the join, and assigns the value of field1 of tableb for the matching row to tableA.field1.

and yes, this is common practice in access.
0
 
LVL 44

Assisted Solution

by:GRayL
GRayL earned 100 total points
ID: 24354953
It will only be an updatable query if the fields in the ON clause are primary keys (no duplicates).  If there was ever an instance where there were two or more records from tableB matching the tableA join, the update would fail.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question