How do I delete data from a table

To delete data from a table in MySQL, you use the DELETE statement followed by the FROM clause, specifying the table name. You can also add a WHERE clause to specify which records should be deleted. Without a WHERE clause, all records in the table will be deleted.

Here is an example of how to use the DELETE statement:

<?php // Creating a connection to the MySQL database $conn = new mysqli("hostname", "username", "password", "database"); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } // SQL query to delete a record $sql = "DELETE FROM tablename WHERE condition"; if ($conn->query($sql) === TRUE) { echo "Record deleted successfully"; } else { echo "Error deleting record: " . $conn->error; } $conn->close(); ?>

delete data MySQL DELETE statement SQL record deletion