Current course:

MySQL delete statement


Description:

An "delete" statement is used to delete an item or items from a table.

The Code:

DELETE FROM table
DELETE FROM students WHERE last='schwan' LIMIT 1

Or, in php:
mysql_query("DELETE FROM table");
mysql_query("DELETE FROM faculty WHERE last='schwan' LIMIT 1");

Explanation:

Without a WHERE clause, the delete statement would delete everything in the table. By adding a where clause and a limit, we make sure we only delete the item(s) that match the criteria. We can also add a LIMIT to our statement to make sure it only deletes X number of entries.