Summer Deals - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Inserting and updating NULLs
Conditions in UPDATE and DELETE
Using values from another column
12. Change values between columns
Inserting data from a query
Summary

Instruction

Oops… The English teacher just realized that she accidentally switched written_exam_scores and oral_exam_scores. The last UPDATE introduced another mistake to the exam table, again with all records for English exams. How can we correct this? Look at the query below:

UPDATE exam
SET 
  written_exam_score = oral_exam_score,
  oral_exam_score = written_exam_score
WHERE subject = 'English'

We set new values for two columns: written_exam_score and oral_exam_score. The first column took the value from oral_exam_score, and the second column took the value from written_exam_score. SQL makes this operation easy.

Exercise

It's time to fix another mistake in our database. Somebody mistook the first name of the student whose ID is 6 for his last name. See if you can use the example query to correct this.