From the course: MySQL Essential Training

Unlock this course with a free trial

Join today to access over 23,200 courses taught by industry experts.

Deleting data

Deleting data

- [Bill] Hi, I'm Bill Wyman. The DELETE statement is used to remove rows from a table. For this lesson, we'll use the scratch database as modified in the previous lessons. I'm going to go ahead and execute this USE scratch statement, and that'll open that database for us. I've pasted in some lines here from the chapter one exercise files. What this does is it creates a simple table called test with three columns, and then it inserts these three rows into it. So I'm going to go ahead and select those four lines and execute that, and you can see down there in our status that worked. And I can SELECT * FROM test, and we can see those three rows that I've just inserted into this new table. Now if we want to delete one of those rows, first, I'm going to copy this SELECT here, and I'm going to say SELECT * FROM test WHERE a = 1. And when I execute that, you see we get one row. Now that's the row I want to delete. I tested my WHERE statement first, because we're going to use that with the…

Contents