General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Updating one table with data from another
Could someone please help me with a technique to update the fields in one record with the data from another record?
I have a student table with a cstud_key Primary Key. I have a second table called xstud which is an Excel import. The xstud table has a cstud_key foreign key, so the student table is linked to the xstud by the cstud_key. Both tables have a student ID field. I want to update the student table's cstud_id with the xstud's cstud_id value. Here is my attempt:
Use student in 0
Use xstud in 0
Update student set student.cstud_id=xstud.cstud_id where student JOIN xstud on student.cstud_key=xstud.cstud.key
or I have tried:
select student
replace student.cstud_id with xstud.cstud_id for student.cstud_key=xstud.cstud_key all
The latter attempt only replaces one value then stops.
This question is something that I know I will use frequently, so I want to understand how to do it. Thanks for your help.
Mike
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only