I have an access data base with three tables named DD, Export , and RPL
I have the result of a inner join betweent EXPORT AND DD which is working fine
Now with those results I want to update a third table RPL which is currently empty but has those fields to be populate for example RPL.[Hotel ID] should be the Hotel ID that results from the query below
SELECT Export.[Hotel ID], Export.[Property Name], Export.[Room Type ID] AS [Parent Room Type ID], Export.[Room Type Code] AS [Parent Room Type Code], Export.[Rate Plan ID] AS [Parent Rate Plan ID], Export.[Expedia Collect Rate Plan Code] AS [Parent Rate Plan Code EC], Export.[Hotel Collect Rate Plan Code] AS [Parent Rate Plan Code HC], Export.[Rate Plan Name] AS [Parent Rate Plan Name] INTO RPL FROM Export INNER JOIN DD ON Export.ExKey = DD.DDKey;
The previous query copies the result into a new table, i want to use the one that exists already Any help it is appreciated it
Thank you
Advertisement
Answer
As your example is not clear, I will write a simpler one to clarify how to update a table use the data joined by other tables,
now there are three tables ATable,BTable,CTable
, the colums of ATable
is id,value1,value2
, the columns of BTable
is id,value1
, the colums of CTable
is id,value2
,
now we will update ATable by use the data joined by the B and C, the SQL is like below:
update ATable a set value1 = t.value1, value2 = t.value2 from ( select b.id, b.value1, c.value2 from BTable b join CTable c on b.id = c.id ) t where a.id = t.id