Once a Delete row in MySQL row has been deleted, it cannot be recovered. It is therefore strongly recommended to make database backups before deleting any data from the database. This can allow you to restore the database and view the data later on should it be required.

Example of MySQL Delete Query

Before we go into more detailed discussion about the SQL DELETE statement, let’s insert some sample data into the movies table to work with. HERE

	DELETE FROM `table_name` tells MySQL server to remove rows from the table ..

	[WHERE condition] is optional and is used to put a filter that restricts the number of rows affected by the DELETE syntax MySQL row query.

If the WHERE clause is not used in the MySQL DELETE query, then all the rows in a given table will be deleted. Executing the above script adds three (3) movies into the movies table. Before we go any further into our lesson, let’s get all the movies in our table. The script shown below does that. Executing the above script gives us the following results. Let’s suppose that the Myflix video library no longer wishes to be renting out “The Great Dictator” to its members and they want it removed from the database. Its movie id is 18, we can use the script shown below to delete row from table MySQL example. Executing the above script in MySQL WorkBench against the Myflix deletes the movie with id 18 from the database table. Let’s see the current status of movies table. NOTE:

the movie with id 18 has not been return in the query result set.

you cannot delete a single column for a table. You can delete an entire row.

Let’s say we have a list of movies we want to delete . We can use the WHERE clause along with IN. Executing the above script deletes movies with IDs 20 and 21 from our movies table.

Summary

	The command Delete in MySQL, is used to remove data that is no longer required from a table.

	The “WHERE clause” is used to limit the number of rows affected by the DELETE query MySQL command.

	Once data has been deleted, it cannot be recovered, it is therefore strongly recommend make backups before deleting data.