Learn SQL Tutorial for Beginners!
Part: Updating rows
Updating rows is done using the
UPDATE statement. Updates are done using two parts: defining which rows should be updated, and the values of the columns
to replace with.
A lot of times an
UPDATE statement will aim to replace one row, in which the query will use the primary key of the table to select the row to update.
Here is the syntax of an
UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE key = value
Let’s look at an example of how an
UPDATE statement works.
.exec CREATE TABLE customers (first_name NOT NULL, last_name NOT NULL, age); INSERT INTO customers (first_name, last_name, age) VALUES ("John", "Doe", 23), ("Eric", "Smith", 26); SELECT * FROM customers; UPDATE customers SET last_name = "Heart" WHERE first_name = "John"; SELECT * FROM customers;
This tutorial is based on Interactive Tutorials license
If you want to submit a tutorial, please do contact us via info at coursesim.
If you want to report a tutorial please contact us in the same way as above so we can adjust or take it down.