Deals Of The Week - 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
Inserting data from a query
Summary
15. Summary

Instruction

Amazing! Let's summarize what we've learned.

We can:

  • Insert data using NULLs for unknown values in a row:
    INSERT INTO student 
    VALUES (21, 'Tom', NULL, 'Muller');
    
  • Change values using NULL and UPDATE:
    UPDATE exam 
    SET written_exam_score = NULL
    WHERE id = 5;
    
  • Change a value in a column or delete a row if the column contains a NULL:
    UPDATE student
    SET last_name = 'unknown' 
    WHERE last_name IS NULL;
    DELETE FROM student 
    WHERE last_name IS NULL;
  • Update or delete using AND and OR to meet certain conditions:
    DELETE FROM exam 
    WHERE subject = 'Spanish' 
      AND (written_exam_score IS NULL 
        OR oral_exam_score IS NULL)
  • Use INSERT INTO to insert data from a SELECT query:
    INSERT INTO student_history(id, first_name, last_name)
    SELECT id, first_name, last_name
    FROM student;

Exercise

Click Next exercise to finish this part.