MySQL Wildcards

MySQL Wildcards

MySQL Aliases

MySQL Aliases

MySQL Data Types

MySQL Data Types

MySQL Interview Questions

MySQL Interview Questions and Answers


MySQL Delete Statement

MySQL DELETE statement allows you to delete existing records in a table within the database. By using delete statement, we can delete records on the basis of conditions.

Note: Be careful when deleting records in a database table! use WHERE clause, If you omit the WHERE clause, all records in the database table will be deleted!

MySQL DELETE TABLE Syntax

To detele data from existing table, use the following syntax:

Syntax

DELETE FROM tablename WHERE Condition;

Parameters:

tablename: The table name from which you want to delete the data.

Condition: To check specific condition before delete the data. The conditions parameter is optional.

MySQL DELETE TABLE Data example

The following MySQL statement to delete the customer "Sunil Shetty" from "tblCustomerLoan" table:

Example

DELETE FROM tblCustomerLoan WHERE firstName = 'Sunil' AND lastName = 'Shetty';

Note:

In the above example, we have deleted the record for customer "Sunil Shetty".

You can use MySQL Command Line Client to delete data from "tblCustomerLoan" table. It will look like this:

Show DELETE Data Example

You can check the deleted data from table by the following query:

Example

SELECT * FROM  tblCustomerLoan; 

You can use MySQL Command Line Client to check the deleted data in table. It will look like this:

MySQL DELETE Data example for all records

The following MySQL statement to delete all records from "tblCustomerLoan" table:

Example

DELETE FROM tblCustomerLoan;

OR

DELETE * FROM tblCustomerLoan;