P
Paul W Smith
I am trying to understand how update queries work.
It is so simple when you are just typing in the new value with which to
update the table - plenty of examples on this!
However I want to understand how to use the result of one query to update a
table.
I have created two simple tables:
TableA
A B
Z 1
Y 2
X 3
TableB
A B
Z 11
Y 22
X 33
SELECT TableA.B, TableB.B FROM TableA INNER JOIN TableB ON TableA.A =
TableB.A;
This works fine and updates the value in TableB over the old value in
TableA.
Now I add some additional values to TableB
TableB
A B
Z 11
Y 22
X 33
Z 44
Y 55
X 66
I then produce a query (saved as Query2) that returns just the max(B) for
each A
SELECT TableB.A, Max(TableB.B) AS MaxOfB FROM TableB GROUP BY TableB.A;
Now I try to Update TableA using this:
UPDATE TableA INNER JOIN Query2 ON TableA.A = Query2.A SET TableA.B =
[Query2]![MaxOfB];
To me this should work, but I get a dialog box which says:
"Operation must use an updateable query."
What is the problem?
It is so simple when you are just typing in the new value with which to
update the table - plenty of examples on this!
However I want to understand how to use the result of one query to update a
table.
I have created two simple tables:
TableA
A B
Z 1
Y 2
X 3
TableB
A B
Z 11
Y 22
X 33
SELECT TableA.B, TableB.B FROM TableA INNER JOIN TableB ON TableA.A =
TableB.A;
This works fine and updates the value in TableB over the old value in
TableA.
Now I add some additional values to TableB
TableB
A B
Z 11
Y 22
X 33
Z 44
Y 55
X 66
I then produce a query (saved as Query2) that returns just the max(B) for
each A
SELECT TableB.A, Max(TableB.B) AS MaxOfB FROM TableB GROUP BY TableB.A;
Now I try to Update TableA using this:
UPDATE TableA INNER JOIN Query2 ON TableA.A = Query2.A SET TableA.B =
[Query2]![MaxOfB];
To me this should work, but I get a dialog box which says:
"Operation must use an updateable query."
What is the problem?