DELETE
Example
Section titled “Example”DELETE FROM CustomersWHERE CustomerName='John Doe';Output
Section titled “Output”Query OK, 1 row affected (0.01 sec)Explanation
Section titled “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
Section titled “Example”DELETE FROM employees WHERE employee_id = 101;Output
Section titled “Output”DELETE 1Explanation
Section titled “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:
Section titled “Example:”DELETE FROM EmployeesWHERE EmployeeID = 5;Output:
Section titled “Output:”(1 row(s) affected)Explanation
Section titled “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
Section titled “Example”DELETE FROM employeesWHERE employee_id = 123;Output
Section titled “Output”1 row deleted.Explanation
Section titled “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
Section titled “Example”DELETE FROM EmployeesWHERE EmployeeID = 7;Output
Section titled “Output”Query OK, 1 row affectedExplanation
Section titled “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.