Deleting Rows from Tables
Explore how to use the SQL delete command to remove rows from MySQL tables safely. Learn to specify conditions with the where clause to delete only the intended data, verify with select queries, and avoid deleting entire tables accidentally.
We'll cover the following...
We'll cover the following...
Syntax for the delete query
Let’s look at the delete query below:
- The
deletekeyword is used to delete any data from the table. - This item tells us which table we want to delete data from. In this case, it’s
customers. - The
whereclause is given at thedeletestatement between the table name and the condition, depending on what data we want to delete. - In the end, we impose the condition to delete the record,
name = "John papa".
Let’s learn more about the delete command. What if we wanted to delete the customer with the name John Papas?
We can use the following command to delete a row ...