DEV Community

nadirbasalamah
nadirbasalamah

Posted on

MySQL tutorial - 6 Deleting the data

In MySQL, data inside the table can be deleted with DELETE query. This query is really crucial because the condition of the data needs to be specified. If the condition is missing, all data inside table will be deleted.

This is the basic query structure of delete operation. Notice that the condition is specified with WHERE clause.

If WHERE clause is not used, all data inside the table will be deleted.

DELETE FROM table_name WHERE conditions
Enter fullscreen mode Exit fullscreen mode

This is the example of delete operation inside table called shop. The data that will be deleted is a data that has an id equals 1.

DELETE FROM shop WHERE id = 1;
Enter fullscreen mode Exit fullscreen mode

If the delete operation is completed, there is a number of rows that affected inside the table.

I hope this article is helpful for learning SQL, If you have any thoughts or comments you can write in the discussion section below.

Top comments (0)