Update Rows Cheat Sheet < Introduction to SQL

 


Concepts in Focus

  • Update Rows
  • SQL – Case Insensitive

Database The database consists of a

player
table that stores the details of players who are a part of a tournament.
player
table stores the name, age and score of players.

Update Rows

UPDATE
clause is used to update the data of an existing table in database. We can update all the rows or only specific rows as per the requirement.

Update All Rows

Syntax

UPDATE
table_name
SET
column1 = value1;
SQL

Example:

Update the

score
of all players to 100 in the
player
table.

UPDATE
player
SET
score = 100;
SQL

Update Specific Rows

Syntax

UPDATE
table_name
SET
column1 = value1
WHERE
column2 = value2;
SQL

Example

Update the

score
of "Ram" to 150 in the
player
table.

UPDATE
player
SET
score = 150
WHERE
name = "Ram";
SQL

Try it Yourself!

The database contains a

student
table that stores the information of name, percentage and scholarship amount of students.

  1. Update the
    scholarship_amount
    of all students to 15000 in the
    student
    table.
  2. Update the
    scholarship_amount
    of "Raju" to 25000 in the
    student
    table.

SQLite is Case Insensitive!

  • Query 1
SELECT
*
FROM
player;
SQL
  • Query 2
select
*
from
player;
SQL
Note
Best Practice: Both Query 1 and Query 2 gives the same output. But, it is recommended to write keywords in upper case to make the query more readable. Prefer Query 1 format over Query 2.

Post a Comment

Please Select Embedded Mode To Show The Comment System.*

Previous Post Next Post

Contact Form