Contact Our Development Team
Free Code Tutorials & Open Source Code
MySQL Queries - Delete
Tutorials > MySQL > Queries - Delete
Deleting records in MySQL
Occasionally, you will find the need to delete records in your MySQL tables. The most important thing to remember about the DELETE query is that it is not reversible - if you delete something you didn't mean to you will need to restore your database from a backup - so make sure that you have tested your queries before you run them. There is no "Recycle Bin" or "Trash" in MySQL, once something is deleted it's gone!

With that in mind, the DELETE query is simple:
SELECT * FROM `customers`
Name: Steven Smyth - Address: 123 Fake Street - Tax ID: 123456 - Customer ID: 1
Name: Daniel Davidson - Address: 45 Made Up Road - Tax ID: 789012 - Customer ID: 2
Name: Tom Thompson - Address: 1 Not Real Close - Tax ID: 654321 - Customer ID: 3
Name: Eddie Ericson - Address: 975C Imaginary Drive - Tax ID: 135792 - Customer ID: 4
DELETE FROM `customer` WHERE `customerid` = '3'
SELECT * FROM `customers`
Name: Steven Smyth - Address: 123 Fake Street - Tax ID: 123456 - Customer ID: 1
Name: Daniel Davidson - Address: 45 Made Up Road - Tax ID: 789012 - Customer ID: 2
Name: Eddie Ericson - Address: 975C Imaginary Drive - Tax ID: 135792 - Customer ID: 4
Page Responses
Currently there have been no responses to this page...
If you have anything to contribute to this tutorial, found a bug, or know a better way of achieving the same goal, please leave your response below.
     
Copyright ©2009, Wired IDS Ltd. | Licensed under Creative Commons Attribution Share-Alike | Load time: 0.2953 seconds