开发者

Copying a field to another table in Access

开发者_运维技巧

I'm a bit embarassed asking this here, but here goes:

I've got two tables, which you can see here:

http://img411.imageshack.us/img411/4562/query.jpg

I need to copy the effortid from the one table into the other, making sure that the values still maintain the correction relationships. The primary key for each is a combination of loggerid & datetime. What's the best way to do this?

Thanks in advance, and don't make fun :)


Change it to an Update Query instead. The joins should function correctly, but will not add missing rows. To do that, you would use an Append Query, like you have setup, but with a left join and a check for nulls. The sample below updates the LogID table with information residing in LogSiteID table.

Append Missing Records from Logger Site ID to LogID

INSERT INTO logID ( [Datetime], loggerid, temp, effortid )
SELECT ls.datetime, ls.loggerid, ls.temp, ls.effortid
FROM logID AS l RIGHT JOIN [Logger Site ID] AS ls ON (l.temp = ls.temp) AND (l.loggerid = ls.loggerid) AND (l.Datetime = ls.datetime)
WHERE (((l.loggerid) Is Null));

Update effortids from Logger Site ID to LogID

UPDATE logID AS l INNER JOIN [Logger Site ID] AS ls ON (l.Datetime = ls.datetime) AND (l.temp = ls.temp) AND (l.loggerid = ls.loggerid) SET l.effortid = [ls].[effortid];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜