Two tables:
COURSE_ROSTER – contains
COURSE_IDas foreign key toCOURSESUSER_IDas field I need to insert intoCOURSES
COURSES – contains
COURSE_IDas primary keyINSTRUCTOR_IDas field that needs to be updated withUSER_IDfield fromCOURSE_ROSTER
What would the UPDATE sql syntax be? I am trying this, but no good… I’m missing something and I can’t find it online.
UPDATE COURSES SET COURSES.INSTRUCTOR_ID = COURSE_ROSTER.USER_ID WHERE COURSE_ROSTER.COURSE_ID = COURSES.COURSE_ID
Not all database vendors (SQL Server, Oracle, etc.) Implement Update syntax in the same way… You can use a join in SQL Server, but Oracle will not like that. I believe just about all will accept a correclated subquery however
NOTE: The column User_ID in Course_Roster would probably be better named as InstructorId (or Instructor_Id) to avoid confusion