Jose: Hi guys and welcome back.
In this video we're going to learn
how to delete rows from a database
and we're also going to implement this in our app.
So Delete From looks like this,
we've got "Delete from users where surname equal Smith."
So the first part tells the database
that we want to delete rows from the user's table,
by default that's going to delete everything.
So this second part here, the Where clause,
filters them so that we only delete
the rows that match this clause.
Otherwise it's going to delete everything.
Seriously important.
Remember the Where clause, just as we did with the update,
otherwise everything's going to be deleted,
and you'll get to keep the table but none of the contents.
So that's pretty important.
Don't forget about that.
Let's go into our code editor
and work on deleting rows from our table.
All right, so what we're going to do is create our Query,
that takes care of deleting movies.
And as you know, it's really straight forward,
"Delete movie" for example can be " Delete from movies".
And here we're telling SQL
that we want to delete something from the movies table.
And we wanna do "Where title equal question mark"
and that means that in the function
we are going to pass in the argument with the titles
that we want to delete from the table.
We're going to be re-implementing this file for stage two
in the next video but I wanted to show you
how this works in DB Browser as well,
so let's go over to that.
So here I've opened DB Browser.
If I go to Browse Data,
you can see that I've got "The Matrix" here.
And if we go to the Execute SQL tab,
we can do "Delete from movies".
Remember if we just run this,
that's gonna delete everything from the movie's table.
At the moment we only have one row so it's not a big deal
but we always want to include a Where clause.
So we'll do "Delete from movies where title equal"
And now we pass in the string inside quotation marks,
single quotation marks, and that's "The Matrix"
And now we can run this,
and you can see that get "Query executed successfully."
We go back to Browse Data, the movie's gone.
All right, thank you guys for watching this video.
We're going to go into the next one
and re-implement the database.py file.
I'll see you there.