The SQL UPDATE Clause is use to enable us can change the data that store in the Table.
The UPDATE clause syntax is:
UPDATE [TABLE NAME]
SET[COLUMN 1] = [VALUE 1], [COLUMN 2] = [VALUE 2]
WHERE [COLUMN] = [CONDITION]
EXAMPLE :
We can try to change the score for Kenny to 2300 in the table below.
Table GameScores
PlayerName | Department | Scores |
Jason | IT | 3000 |
Irene | IT | 1500 |
Jane | Marketing | 1000 |
David | Marketing | 2500 |
Paul | HR | 2000 |
James | HR | 2000 |
Vivian | Marketing | 2500 |
Kenny | HR | 0 |
SQL statement :
UPDATE GameScores
SET Scores = 2300
WHERE PlayerName = 'Kenny'
After execute the SQL command. The table will look like like this. Column which is highlighted with Yellow is the data that been Changed.
Table GameScores
PlayerName | Department | Scores |
Jason | IT | 3000 |
Irene | IT | 1500 |
Jane | Marketing | 1000 |
David | Marketing | 2500 |
Paul | HR | 2000 |
James | HR | 2000 |
Vivian | Marketing | 2500 |
Kenny | HR | 2300 |