i new , programming , wondering if me sql query. have 3 tables. table 1 called student(id,number,teacherid) , table 2nd table called studentupdate (studentid, teacher_number) , third table called teacher (id, number,studentid).
i update table 1 (student table) values table 2 (student update) based on teacherid . how do when table 2 contains teacher number not id ? using sql server 2012. in advance
you can use following query:
update s set teacherid = su.teacher_number student s join teacher t on s.teacherid = t.id join studentupdate su on s.id = su.studentid the above query performs update using 2 join operations:
studentteacherbased on ids of teacher andstudentupdateteacherbased on id of student.so extract table
studentupdateinfo requiredupdate(based on limited info given in op).