SQL Getting Started Tutorial: SQL INSERT and update simple tutorial
Okay, let's start with the SQL Insert Tutorial.
The declaration that is inserted is used to insert a new record table.
In the Insert Declaration
The Insert Declaration is used to insert a new column in a table.
Database Insert Syntax
May be written in two forms of insert speech.
The first form of data without specific column names will be inserted, with only their values:
INSERT into table_name
VALUES (value1, value2, Value3,...)
The second form specifies the column name and insert:
INSERT into table_name (column1, Column2, Column3,...)
VALUES (value1, value2, Value3,...)
OK, let's take a look at the SQL Update Tutorial.
The UPDATE statement is used to update the record table.
UPDATE statement
The UPDATE statement is used to update the existing record table.
Updated SQL syntax
UPDATE table_name
SET column1=value, column2=value2,...
WHERE Some_column=some_value |
Take a look at an updated example. Let's watch the table ' a ' first.
_id |
LastName |
FirstName |
| Address
| City
1 |
Hansen |
Ola |
TIMOTEIVN 10 |
Sandnes |
2 |
Svendson |
Tove |
BORGVN 23 |
Sandnes |
3 |
Pettersen |
Kari |
STORGT 20 |
Stavanger |
4 |
Nilsen |
Johan |
Bakken 2 |
Stavanger |
5 |
Tjessem |
Jakob |
|
|
Then execute the following SQL UPDATE statement.
UPDATE a SET address= ' Nissestien ', city= ' Sandnes ' WHERE lastname= ' Tjessem ' and firstname= ' Jakob '
_id |
LastName |
FirstName |
| Address
| City
1 |
Hansen |
Ola |
TIMOTEIVN 10 |
Sandnes |
2 |
Svendson |
Tove |
BORGVN 23 |
Sandnes |
3 |
Pettersen |
Kari |
STORGT 20 |
Stavanger |
4 |
Nilsen |
Johan |
Bakken 2 |
Stavanger |
5 |
Tjessem |
Jakob |
Nissestien 67 |
Sandnes |
This is the record we want to update Firstname= ' Jakob '.