You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description: 'Modifies existing records in a table according to specified conditions.'
4
+
Subjects:
5
+
- 'Data Science'
6
+
- 'Computer Science'
7
+
Tags:
8
+
- 'Database'
9
+
- 'Queries'
10
+
- 'PostgreSQL'
11
+
- 'MySQL'
12
+
CatalogContent:
13
+
- 'learn-sql'
14
+
- 'paths/analyze-data-with-sql'
15
+
---
16
+
17
+
The **`UPDATE`** statement in SQL is used to modify existing records in a table. This powerful **Data Manipulation Language (DML)** command allows developers to update one or multiple rows simultaneously.
18
+
19
+
## Syntax
20
+
21
+
```pseudo
22
+
UPDATE table_name
23
+
SET column1 = value1, column2 = value2, ...
24
+
WHERE condition;
25
+
```
26
+
27
+
-`table_name`: The name of the table containing the data to be updated.
28
+
-`SET`: Specifies the columns to update and their new values.
29
+
-`condition`: An optional clause that specifies which rows to update. If omitted, all rows in the table are updated.
30
+
31
+
## Example
32
+
33
+
Let's say there's a table `Employees`:
34
+
35
+
| ID | Name | Department | Salary |
36
+
| --- | ----- | ---------- | ------ |
37
+
| 1 | John | HR | 50000 |
38
+
| 2 | Alice | IT | 60000 |
39
+
| 3 | Bob | Sales | 45000 |
40
+
41
+
To update Bob's salary in the Sales department, the following query can be used:
0 commit comments