H I O X INDIA
MySQL Tutorial
Google
Web hscripts.com
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Directories 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)   Bookmarks :-)  
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

Mysql Tutorial
Introduction
How to Install
Database
Datatypes
Tables
INSERT
SELECT
UPDATE
DELETE
Operators
Functions
Ask Your Doubts
Feedback





UPDATE Statement


Topic

How to use UPDATE query?
How to modify or change an existing column or row?
Update Data in MySQL



Explanation


UPDATE Statement :

    The UPDATE query is used to change or modify the existing values in a table.

The Update Syntax is


UPDATE tbl_name SET 
col_name1=expr1 [, col_name2=expr2 ...]
[WHERE where_condition];
    The UPDATE query updates the columns of existing rows in a table with the new values. The SET clause is used to indicate which columns to be modified. The WHERE clause is used to specify the conditions that identify which rows to be updated.

    The following example will set the address of the student to a new address.

mysql> update student set address='welling street' where
address='victoria street';
Query OK, 1 row affected (0.03 sec)
Rows matched: 1  Changed: 1  Warnings: 0
    But this will set all the address of the students who ever lives in victoria street will be changed to welling street.

    Suppose if we want to set the address of a single student to a new address then we can choose the below option.

mysql> update student set address='welling street' where name='jack';
Query OK, 1 row affected (0.03 sec)
Rows matched: 1  Changed: 1  Warnings: 0
    If we want to change a students mark we can use the below statement.

mysql> update student set marks=100 where name='david';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0
    This can also be rewritten as the following.

mysql> update student set marks=marks+2 where name='david';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0
    In UPDATE statement we can also use the arithmetic operations.



others


        MySQL is the most popular open source database Management system. Being a open source anyone can use and change the software for their needs. Hope you enjoy this tutorial. We welcome your Valuable feedbacks or suggestions on this MySQL tutorial. This is a copyright content.


privacy policy     license     sitemap
© 2004-2005 HIOX INDIA - hioxindia.com

Other Links