使用SQL从另一个Access表更新MSAccess表 [英] Update MSAccess table from another Access table using SQL
问题描述
我正在尝试使用Final中的值更新表Original.我是SQL的新手,但是我已经花了两个小时尝试更改各种样本以满足我的需求.我正在使用Access 2007.
I am trying to update table Original with the values in Final. I'm a newb to SQL, but I have been at this for two hours trying to change various samples to fit my needs. I am using Access 2007.
UPDATE
Original o
SET
o.[Assest Description] = (
SELECT f.[Assest Description] FROM Original o, Final f
WHERE o.[Assest No] = f.[Assest No])
WHERE o.[Assest No] = Final.[Asset No]
推荐答案
我不确定您的select
语句仅返回一行.如果要使用select
语句对表执行更新,则必须 确保它仅返回一行.
I'm not sure your select
statement returns only one row. If you want to perform an update on a table using a select
statement for assignment, you must be sure that it returns only one row.
除此之外,您可以考虑下一个解决方案:
Besides that, you may consider the next solution:
update
Original as o
inner join Final as f on o.[Assest No] = f.[Assest No]
set
o.[Assest Description] = f.[Assest Description]
请注意,只有当[Assest no]
在Original
和Final
表中均是唯一键并且它们之间具有适当的关联性时,这才能正常工作.
Notice that this will only work correctly if both [Assest no]
is a unique key in both Original
and Final
tables, and they are properly related.
这篇关于使用SQL从另一个Access表更新MSAccess表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!