Delete Query in MySQL

Profile picture for user arilio666

To delete an existing record from the table, the delete statement is used when coupled with the where statement. It can be pretty powerful in isolating and deleting certain records off the table.

MySQL Delete Statement Syntax

DELETE FROM table_name WHERE condition;

Example: MySQL Delete Row

For example purpose, we will use the info table here.

delete command in mysql

Let us delete the Name Lokesh from the info table.

DELETE FROM info  WHERE Name='Lokesh';

We can see here that the entire record related to the Name Lokesh has been erased.

Delete All Rows from Table MySQL

  • It is also possible that we can delete the whole record of the table without affecting the table.
  • This means the table structure, attributes and indexes will still be intact.
DELETE FROM info;

So this is how we can effectively use the delete statement in MySQL to delete all records from table info.

Tags