• 20 hours
  • Medium

Free online content available in this course.

course.header.alt.is_video

course.header.alt.is_certifying

Got it!

Last updated on 11/25/19

Destroy records

Log in or subscribe for free to enjoy all this course has to offer!

Now to the D of CRUD!  Let's destroy a record!

In phpMyAdmin, browse the dog table, and click the word Delete at the beginning of a row. In the interface, it will ask if you really want to do this. 

When you write your own code to perform SQL operations, the database won't make sure you know what you are doing, so be careful!

But for now, click OK.

The SQL that deleted my record was this:

DELETE FROM `dog` WHERE `dog`.`dog_id` = 5;

If I want to delete multiple rows of the table, I could use a different operator than the equals sign, like the greater than sign to delete all records with  dog_id s greater than 2 :

DELETE FROM `dog` 
WHERE `dog`.`dog_id` > 2;

When you click the Delete button on a line or two, the GUI will then ask you if you are sure you want to make the delete. If you try the same thing using the SQL window, that courteous window won't appear and your delete will go through (assuming its a valid statement).

Next, we will examine SELECT statements that combine our different tables!

Example of certificate of achievement
Example of certificate of achievement