MySQL DELETE

How to delete data and tables from a MySQL database.

The DELETE command is used to delete records from your database. When you delete a record there is no way of getting it back so you may want to back up your database when you run delete queries and you'll probably want to limit your queries using a LIMIT clause if you can. The following query shows the syntax for a DELETE query.

DELETE FROM tablename WHERE column='value'

The following query will delete all records in a table while keeping the table and table structure.

DELETE FROM tablename

To delete all the data in a table and delete the table itself use the following:

DROP TABLE tablename

We are using the following database table we already created named "users" with firstname, lastname, age, and state.



DELETE

MySQL Code

$query="DELETE FROM users WHERE firstname='John'";




Results




 
Bookmark this page:
   
Rate this page:
  • Currently 2.99/5
  • 1
  • 2
  • 3
  • 4
  • 5

Rating: 3.0/5 (154 votes)



Comments:

please post comments
admin November 21, 2006

 
Nickname:
Comment:
Security: 1+1=
Hosts
Lunarpages.com Web Hosting
iPowerWeb

Domain Registrars
PPC Networks
Logos
Affiliate Networks
Resources