The SQL UPDATE Statement:

The SQL UPDATE statement is used to modify the data in a table .

Syntax:

UPDATE table_name SET column_name = new_value WHERE column_name = some_value

Example:

Using ‘UserInfo’ Table

LastName FirstName Address City Year
Hansen Ola Timoteivn 10 Sandnes 1951
Svendson Tove Borgvn 23 Sandnes 1978
Rasmussen Storgt 67

Query:
With this query we will add first name of a user where last name of user is Rasmuseen.

UPDATE UserInfo SET FirstName = ‘Nina’ WHERE LastName = ‘Rasmussen’

The Result:

LastName FirstName Address City Year
Hansen Ola Timoteivn 10 Sandnes 1951
Svendson Tove Borgvn 23 Sandnes 1978
Rasmussen Nina Storgt 67

 

UPDATE Several Columns in a Row:

We can also update data of several columns in a row.

Example:

Using ‘UserInfo’ Table

LastName FirstName Address City Year
Hansen Ola Timoteivn 10 Sandnes 1951
Svendson Tove Borgvn 23 Sandnes 1978
Rasmussen Nina Storgt 67

Query: With following query we are going to change the address and adding city to it.

UPDATE Person SET Address = ‘Stien 12’, City = ‘Stavanger’ WHERE LastName = ‘Rasmussen’

The Result:

LastName FirstName Address City Year
Hansen Ola Timoteivn 10 Sandnes 1951
Svendson Tove Borgvn 23 Sandnes 1978
Rasmussen Nina Stien 12 Stavanger

 

2 responses to “UPDATE Statement”

  1. Laffe says:

    This can be a remarkably amazing powerful resource that you’re offering and you just provide it away cost-free!! I quite like discovering websites which are aware of the particular importance of giving you fantastic learning resource for zero cost. We truly dearly loved examining this article. Appreciate it!

  2. James Warner says:

    I just want to tell you that I am very new to blogging and site-building and certainly liked you’re web-site. Most likely I’m want to bookmark your site . You absolutely come with remarkable articles and reviews. Appreciate it for revealing your website page.

Leave a Reply

Your email address will not be published. Required fields are marked *