R
Richard Hollenbeck
I have a temp table as a work-around because of the need to get data from
several unrelated tables. I don't want to change my relationships at this
time. I think I already have them right. I want to use this table to
insert grades into a classroom activity.
The studentScores table has a composite key of studentID and activityID and
one other field called score.
The temp table was build by an INSERT INTO query and multiple UPDATE queries
from various related tables. The temp table has nine fields: courseCode,
groupID, activityID, activityDescription, score, studentID (AutoNum),
lname, fname, studentNumber (user entered, not key).
The database is under construction, but I have one class entered for sample
data. That class has 20 students. I updated the scores in the temp table
from the studentScores table before I entered the grades which went into the
temp table. This is all done with queries and VBA. Now I have a temp table
with 20 students in it. Now I want to update/append the studentScores
table. If the records don't yet exist, they need to be appended. If grades
have already been entered in the past the records in studentScores need to
be updated. So I wrote the following query:
INSERT INTO studentScores ( studentID, activityID, score )
SELECT temp.studentID, temp.activityID, temp.score
FROM studentScores, temp;
My thinking is that the composite key won't be satisfied until a student is
matched with an activity so the record will be blank until adding a score to
an activity for a student. So I want to write these grades to the table.
In case a record exists I will need to update that data instead.
The problem with this query is that it offers to insert 2960 rows!!!!! The
studentScores table only has about 150 records!
I just got to thinking that I ought to make a composite key for the temp
table. The problem is that the components of that combined key comes from
different tables at different times (from different queries). Therefore, no
one of those queries will provide both halves of the key to make a new
record.
What is wrong with my query? I have a similar problem with the update
query; but when I solve this one, I may have also solved the other.
Thanks. Rich Hollenbeck
several unrelated tables. I don't want to change my relationships at this
time. I think I already have them right. I want to use this table to
insert grades into a classroom activity.
The studentScores table has a composite key of studentID and activityID and
one other field called score.
The temp table was build by an INSERT INTO query and multiple UPDATE queries
from various related tables. The temp table has nine fields: courseCode,
groupID, activityID, activityDescription, score, studentID (AutoNum),
lname, fname, studentNumber (user entered, not key).
The database is under construction, but I have one class entered for sample
data. That class has 20 students. I updated the scores in the temp table
from the studentScores table before I entered the grades which went into the
temp table. This is all done with queries and VBA. Now I have a temp table
with 20 students in it. Now I want to update/append the studentScores
table. If the records don't yet exist, they need to be appended. If grades
have already been entered in the past the records in studentScores need to
be updated. So I wrote the following query:
INSERT INTO studentScores ( studentID, activityID, score )
SELECT temp.studentID, temp.activityID, temp.score
FROM studentScores, temp;
My thinking is that the composite key won't be satisfied until a student is
matched with an activity so the record will be blank until adding a score to
an activity for a student. So I want to write these grades to the table.
In case a record exists I will need to update that data instead.
The problem with this query is that it offers to insert 2960 rows!!!!! The
studentScores table only has about 150 records!
I just got to thinking that I ought to make a composite key for the temp
table. The problem is that the components of that combined key comes from
different tables at different times (from different queries). Therefore, no
one of those queries will provide both halves of the key to make a new
record.
What is wrong with my query? I have a similar problem with the update
query; but when I solve this one, I may have also solved the other.
Thanks. Rich Hollenbeck