UPDATE another table using sub-query
Updates students table based on notes table column
notes.id
UPDATE 
  students 
SET 
  points = points + 1 
WHERE 
  student_id = (
    SELECT 
      student_id 
    FROM 
      notes 
    WHERE 
      notes.id = 1
  )
We can get the same result using explicit join
UPDATE notes
INNER JOIN students ON notes.student_id = students.id
SET students.points = students.points + 1
WHERE notes.id = 1
by Valeri Tandilashvili
4 years ago
MySQL
UPDATE
MySQL Tutorial for Beginners
1
Pro tip: use ```triple backticks around text``` to write in code fences