tags:

views:

36

answers:

1

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 :)

+1  A: 

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];
Clownish Carnage
Hey this is fantastic. Thanks a bunch!It's actually the case where I'm trying to add the logid.effortid to loggersiteid.effortid, including those null values.I'm going to mess about and try to get this working based on your reply.
Jacques Tardie