DELETE

DELETE is a SQL command used to remove rows from a table. This command deletes all records that satisfy the condition specified in the WHERE clause. If the WHERE clause is not included, the command will remove all rows from the table, leaving the table structure intact for new data.

Example

DELETE FROM Customers
WHERE CustomerName='John Doe';

Output

Query OK, 1 row affected (0.01 sec)

Explanation

The DELETE command is used to remove existing records from a MySQL database. In the given example, it removes the record from the ‘Customers’ table where the ‘CustomerName’ is ‘John Doe’. The output indicates that the command has been executed successfully, deleting one row.

Example

DELETE FROM employees WHERE employee_id = 101;

Output

DELETE 1

Explanation

The given SQL command is used to delete a specific record from the employees database table. The query targets the row where the employee_id is equal to 101. If the operation is successful, the output DELETE 1 means that one row has been deleted.

Example:

DELETE FROM Employees
WHERE EmployeeID = 5;

Output:

(1 row(s) affected)

Explanation

The DELETE statement removes a record from the ‘Employees’ table where ‘EmployeeID’ equals 5. The output informs us that one row has been affected, meaning one record was deleted from the table.

Example

DELETE FROM employees
WHERE employee_id = 123;

Output

1 row deleted.

Explanation

The example provided demonstrates an SQL DELETE operation on the employees table. The DELETE command is used to remove records from a database table. In this instance, the operation is singular, aiming to erase the employee record with employee_id set to 123. Upon successful execution, the system reports that one row has been deleted.

Example

DELETE FROM Employees
WHERE EmployeeID = 7;

Output

Query OK, 1 row affected

Explanation

The aforementioned SQL command removes a record from the ‘Employees’ table where the ‘EmployeeID’ is equal to 7. The output message confirms that one row was affected, meaning one record was deleted from the table.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.