-
Notifications
You must be signed in to change notification settings - Fork 0
/
Update Statements
36 lines (25 loc) · 1.08 KB
/
Update Statements
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
The UPDATE statement edits a row in a table.
To change existing records.
EXAMPLE:
The statement below updates the record with an id value of 4 to have the twitter_handle @taylorswift13.
UPDATE celebs
SET twitter_handle = '@taylorswift13'
WHERE id = 4;
1. UPDATE is a clause that edits a row in the table.
2. celebs is the name of the table.
3. SET is a clause that indicates the column to edit.
twitter_handle is the name of the column that is going to be updated
@taylorswift13 is the new value that is going to be inserted into the twitter_handle column.
4. WHERE is a clause that indicates which row(s) to update with the new column value. Here the row with a 4 in the id column is the row that will have the twitter_handle updated to @taylorswift13.
EXAMPLE:
UPDATE celebs
SET twitter_handle = '@taylorswift13'
WHERE id = 4;
SELECT * FROM celebs;
OUTPUT:
Query Results
id name age twitter_handle
1 Justin Bieber 29
2 Beyonce Knowles 42
3 Jeremy Lin 35
4 Taylor Swift 33 @taylorswift13