简体   繁体   中英

UPDATE query joining table and subselect in ACCESS

I am trying to update a field of my table1 using the following code but I receive the following error message:3073 operation must use an updateable query.

UPDATE table1 a 
INNER JOIN (SELECT COUNT(somevalue) AS Total,ID 
FROM ReadsPNPA GROUP BY ID) b 
ON a.ID=b.ID 
SET a.Total = b.Total 

Any ideas? the subselect query works on its own.

Use a DCount expression instead of a subquery to do your UPDATE ...

UPDATE table1 a 
SET a.Total = DCount('somevalue', 'ReadsPNPA', '[ID]=' & a.ID);

Access UPDATE queries are fussy. Techniques like subqueries or GROUP BY cause Access to treat the query as "not updateable". See Why is my query read-only? for more information.

You can use domain aggregate functions (such as DCount , DSum , DAvg , etc.) so that Access will treat the query as updateable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM