How to Delete From MySQL

How to Delete From MySQL thumbnail
Delete records from MySQL.

MySQL, an open-source database, provides small and large companies with a database engine used for desktop and Web applications. The MySQL database tables allow you to insert, edit, retrieve and delete rows. You can delete one or several rows in a MySQL table. The "delete" statement has specific syntax. Following the syntax ensures that you delete the proper records and leave the others intact.

Instructions

    • 1

      Create your delete query template. This gets you started on the query, and it ensures you have the basic parts of the delete statement covered. The following creates a basic delete query:

      delete from customer

      The MySQL statement above deletes all records from the customer table.

    • 2

      Filter the records you delete. Most delete statements are meant to delete only a few records from the database. You can filter out the records deleted using the "where" clause. The following code only deletes customers with a last name of "Smith":

      delete from customer where last_name='Smith'

    • 3

      Use the "limit" keyword to limit the amount of rows deleted. This filters the deleted records even further. For instance, the following code only deletes five records from the customer table:

      delete from customer where last_name='Smith' limit 5

Related Searches:

References

  • Photo Credit computer image by blaine stiger from Fotolia.com

Comments

You May Also Like

Related Ads

Featured