Databases| SQL| MySQL| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Mysql Update 
 

Mysql Update is used to modify the table and set a new value to the column on the basis of condition specified in where clause.

 

Mysql Update

                         

Mysql Update is used to modify the table and set a new value to the column on the basis of condition specified in where clause.

Understand with Example

The section in this Tutorial illustrate an example from 'Mysql Update'.To grasp this example we simply create a table 'Employee' with required fieldname and datatype respectively.

 

 

 

 

Query for creating table name Employee:

mysql> CREATE TABLE Employee(
    ->              Empid int(10),
    ->              Empname varchar(60),
    ->              Salary int(90),
    ->       DOB date
    ->            );
Query OK, 0 rows affected (0.01 sec)

Query for Multiple insertion of data in table:

The Query insert into is used to add the records or rows to the table 'Employee'.

mysql>     INSERT INTO Employee (Empid,Empname,Salary,DOB) VALUES
    ->     (01,'Habib',2014,20041202),
    ->     (02,'Karan',4021,20030411),
    ->     (03,'Samia', 22,20080223),
    ->     (04,'Hui Ling', 25,20081015),
    ->     (05,'Yumie', 29,19990126);
Query OK, 5 rows affected (0.00 sec)
Records: 5  Duplicates: 0  Warnings: 0

Query to view data inserted in table:

To view the detail records from table 'employee' we use select query.

mysql> select * from employee;

Output:-

+-------+----------+--------+------------+
| Empid | Empname  | Salary | DOB        |
+-------+----------+--------+------------+
| 1     | Habib    | 2014   | 2004-12-02 |
| 2     | Karan    | 4021   | 2003-04-11 |
| 3     | Samia    | 22     | 2008-02-23 |
| 4     | Hui Ling | 25     | 2008-10-15 |
| 5     | Yumie    | 29     | 1999-01-26 |
+-------+----------+--------+------------+
5 rows in set (0.00 sec)

Query for  updating data inserted in table:

The Query below is used to update the records in table employee on the basis of condition set in where clause.In this Query we modify or change the value of 'empname' on the basis of condition specified in 'emp id'. 

mysql> update employee set empname='A'where empid=1;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1  Changed: 0  Warnings: 0
mysql>  update employee set empname='b'where empid=2;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql>  update employee set empname='c'where empid=3;
Query OK, 1 row affected (0.02 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql>  update employee set empname='d'where empid=4;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql>  update employee set empname='e'where empid=5;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

Output:-

mysql> select * from employee;
+-------+---------+--------+------------+
| Empid | Empname | Salary | DOB        |
+-------+---------+--------+------------+
| 1     | A       | 2014   | 2004-12-02 |
| 2     | b       | 4021   | 2003-04-11 |
| 3     | c       | 22     | 2008-02-23 |
| 4     | d       | 25     | 2008-10-15 |
| 5     | e       | 29     | 1999-01-26 |
+-------+---------+--------+------------+
5 rows in set (0.00 sec)

 

                         

» View all related tutorials
Related Tags: sql mysql c database file text data import backup load sed port int create tab tex loader example to base

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.