Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Updating Rows in a Table | Updating & Deleting Data
Introduction to SQL

bookUpdating Rows in a Table

The UPDATE statement can be used for updating certain rows from a table.

Following is the syntax of the UPDATE statement:

UPDATE table_name
SET column1 = value1,
        column2 = value2,
        ...
WHERE condition;

The UPDATE statement selects rows from the targeted table based on the given condition and updates them with the values given after the SET keyword, for their corresponding columns.

Example: Updating Students' Data

Consider a table students having the columns name, age, score and grade. By default the grade is set to 'None' for all students.

We would like to change the grade to 'A+' for all the students with a score greater than 90. This can be done using the following query:

UPDATE students
SET 
	grade= 'A+'
WHERE 
	score > 90;

Demonstration:

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 5. ChapterΒ 1

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Awesome!

Completion rate improved to 1.72

bookUpdating Rows in a Table

Swipe to show menu

The UPDATE statement can be used for updating certain rows from a table.

Following is the syntax of the UPDATE statement:

UPDATE table_name
SET column1 = value1,
        column2 = value2,
        ...
WHERE condition;

The UPDATE statement selects rows from the targeted table based on the given condition and updates them with the values given after the SET keyword, for their corresponding columns.

Example: Updating Students' Data

Consider a table students having the columns name, age, score and grade. By default the grade is set to 'None' for all students.

We would like to change the grade to 'A+' for all the students with a score greater than 90. This can be done using the following query:

UPDATE students
SET 
	grade= 'A+'
WHERE 
	score > 90;

Demonstration:

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 5. ChapterΒ 1
some-alt