UXDE dot Net

MySQL Tutorial: Update Query

By -

Here is a tutorial of how to update MySQL table data.

It would be much better if you see my previous articles on

Syntax:

UPDATE table
SET column_1=new value
WHERE required condition
AND other conditions

 

Having the same table in your database

first_name last_name age date_registered
 1  Bob  Samuel  23  2012-12-15 09:56:42
 2  Anna  Smith  21  2012-12-16 10:26:02
 3  Dan  Brown  19  2012-12-17 11:54:22
 4  Agatha  Christie  17  2012-12-18 20:56:02
 5  John  Watson  30  2012-12-19 14:46:43
 6  Daniel  Patinson  21  2012-12-20 10:56:02

Let us perform an update operation:

 

Updating single record:

 

Query:

UPDATE employee_data
SET first_name = ‘Marry’
WHERE first_name = ‘Agatha’

 

Result:

mysql_update_query_tutorial

and the table now looks as:

first_name last_name age date_registered
 1  Bob  Samuel  23  2012-12-15 09:56:42
 2  Anna  Smith  21  2012-12-16 10:26:02
 3  Dan  Brown  19  2012-12-17 11:54:22
 4  Marry  Christie  17  2012-12-18 20:56:02
 5  John  Watson  30  2012-12-19 14:46:43
 6  Daniel  Patinson  21  2012-12-20 10:56:02

Updating single record:

Advertisement

Multiple records can be updated separating by commas.

Query:

UPDATE employee_data
SET first_name = ‘Amiley’, last_name = ‘Ken’
WHERE first_name = ‘Anna’

 

Result:

mysql-update-multiple-records

and the table now looks as:

first_name last_name age date_registered
 1  Bob  Samuel  23  2012-12-15 09:56:42
 2  Amiley  Ken  21  2012-12-16 10:26:02
 3  Dan  Brown  19  2012-12-17 11:54:22
 4  Marry  Christie  17  2012-12-18 20:56:02
 5  John  Watson  30  2012-12-19 14:46:43
 6  Daniel  Patinson  21  2012-12-20 10:56:02

Farheen Bibi

You can find Farheen on , and .

2 Comments to MySQL Tutorial: Update Query

Leave a Reply