I'm using microsoft Access.
If this query:
(SELECT FERMENT.FermentId
FROM FERMENT
INNER JOIN [BELGIUM BEER]
ON
FERMENT.FermentName = [BELGIUM BEER].FermentId ORDER BY [BELGIUM BEER].BeerId) a
returns FermentId, how do I update a different table with that column?
Example:
UPDATE EXAMPLETABLE
SET EXAMPLETABLE.FermentId = a.FermentId
FROM a
(SELECT FERMENT.FermentId
FROM FERMENT
INNER JOIN [BELGIUM BEER]
ON
FERMENT.FermentName = [BELGIUM BEER].FermentId ORDER BY [BELGIUM BEER].BeerId) a
Not sure what the relation of EXAMPLETABLE with your data is, but in general.
In Access the SET part is after the join, also skip the select part en the order by. Should be something like this
If it doent work try building the join in the query builder
Assuming that the sub-query returns more than one value, you need a second key to connect (JOIN) between the new values and the table you want to update (EXAMPLETABLE).
In this case I would try something like this:
If this isn't the case and the sub-query returns a single value, try something like this:
Note that in this case you need to guarantee that the sub-query will never return more than one row!
There is no need for defining a relationship between the two tables. Answer 10 (Arnoldiusss) is almost correct and by far the most comprehensible and shortest solution. And the fastest in execution. But the example code is wrong. The next code comes from one of my applications and runs fine in MS ACCESS 2013.
For "the Belgian Beer Case" (I love that expression;-) it would be: