TL;DR - The SQL UPDATE command allows you to modify the data records in the table. It is usually used together with the WHERE clause: if you don't use it, all the records in the table will be updated.
Contents
The syntax for SQL UPDATE
Example
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
Examples using a demo database
The Developers table
ID | Name | City | Country |
---|---|---|---|
1 | Tom Kurkutis | New York | USA |
2 | Ana Fernandez | London | UK |
3 | Antonio Indigo | Paris | France |
4 | Aarav Kaelin | Delhi | India |
5 | Andrew Tumota | Miami | USA |
Pros Main Features
- Easy to use with a learn-by-doing approach
- Offers quality content
- Gamified in-browser coding experience
- The price matches the quality
- Suitable for learners ranging from beginner to advanced
- Free certificates of completion
- Focused on data science skills
- Flexible learning timetable
Pros Main Features
- Simplistic design (no unnecessary information)
- High-quality courses (even the free ones)
- Variety of features
- Nanodegree programs
- Suitable for enterprises
- Paid Certificates of completion
Pros Main Features
- A wide range of learning programs
- University-level courses
- Easy to navigate
- Verified certificates
- Free learning track available
- University-level courses
- Suitable for enterprises
- Verified certificates of completion
Updating a single entry
Example
UPDATE Developers
SET City = 'Berlin', Country= 'Germany'
WHERE Name = 'Antonio Indigo';
The result
ID | Name | City | Country |
---|---|---|---|
1 | Tom Kurkutis | New York | USA |
2 | Ana Fernandez | London | UK |
3 | Antonio Indigo | Berlin | Germany |
4 | Aarav Kaelin | Delhi | India |
5 | Andrew Tumota | Miami | USA |
Updating entries that comply with a defined condition
Example
UPDATE Developers
SET Name='Ben'
WHERE Country='India';
The result
ID | Name | City | Country |
---|---|---|---|
1 | Tom Kurkutis | New York | USA |
2 | Ana Fernandez | London | UK |
3 | Antonio Indigo | Berlin | Germany |
4 | Ben | Delhi | India |
5 | Andrew Tumota | Miami | USA |
Updating all the entries
Example
UPDATE Developers
SET Name='Ben';
The result
ID | Name | City | Country |
---|---|---|---|
1 | Ben | New York | USA |
2 | Ben | London | UK |
3 | Ben | Berlin | Germany |
4 | Ben | Delhi | India |
5 | Ben | Miami | USA |