Update Join
UPDATE students s JOIN marks m ON s.roll = m.roll SET s.marks = m.score WHERE m.subject = 'Maths'; copy a value across tables. JOIN picks the rows, SET changes them.
Preview with SELECT s.roll, s.marks, m.score FROM … the same JOIN. Then UPDATE.
Trap: UPDATE without JOIN when the new value lives in another table. Trap: multiple marks rows per student — which one wins is messy; be specific in WHERE.
On the example next to this theory — Update Join — uPDATE changes existing rows — always scope with WHERE.
students.id
=
marks.student_id
│
▼
one result rowExam tip
UPDATE s JOIN m ON s.roll = m.roll SET s.marks = m.score;