Databases| SQL| MySQL| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
MySQL remove 
 

We can use MySQL Delete statement to implement the removal on the database.

 

MySQL remove

                         

We can use MySQL Delete statement to implement the removal on the database. If you want to remove any record from the MySQL database table then you can use MySQL Delete From. Here in this section we will describe how you can use Delete From in your MySQL query to remove records. Syntax is as given below :

 

 

 

 

 

Syntax :

 DELETE from table [ WHERE clause ];

WHERE clause is used when you want to perform query on some specific data records. If we don't use WHERE it will remove all records from the database table. In WHERE clause we can provide some specific condition, based on which query would be resulted. 

Explanation :

Before firing the query we must have one or more table in any database. For our example we have created a table "users", for this table structure is as given below :

Query
CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `username` varchar(50) default NULL,
  `password` varchar(50) default NULL,
  `email` varchar(50) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*Data for the table `users` */
insert  into `users`(`id`,`username`,`password`,`email`)
 values (1,'Ankur','ankur','ankur@yahoo.com'),
(2,'Vinay','vinay','vinay@yahoo.com');
mysql> select * from users;
Output
+----+----------+----------+-----------------+
| id | username | password | email           |
+----+----------+----------+-----------------+
|  1 | Ankur    | ankur    | ankur@yahoo.com |
|  2 | Vinay    | vinay    | vinay@yahoo.com |
+----+----------+----------+-----------------+
2 rows in set (0.00 sec)

Now on this table we can execute query for delete . Here we will remove all information of the user with the id value 2.

Query  
mysql> DELETE from users where users.id = 2;
Query OK, 1 row affected (0.01 sec)
mysql> select * from users;
Output
+----+----------+----------+-----------------+
| id | username | password | email           |
+----+----------+----------+-----------------+
|  1 | Ankur    | ankur    | ankur@yahoo.com |
+----+----------+----------+-----------------+
1 row in set (0.00 sec)

As you can see in output that it has removed the record with the id value 2.

                         

» View all related tutorials
Related Tags: sql mysql c database table ant data delete remove state tab move if record statement to base e can use

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.