The UPDATE statement is used to update records in a table.
Create a Database named "Studysql" and a table named "tbl_biodata"
Right click on the database Studysql and select new query.Then we can write queries as per the requirements.
( Click here to know how created this table )
==================================================================================
In the previous chapter ( SQL "INSERT INTO" Statement ) , we inserted a new row "Resmi" as shown :
Now , we want to update the details of "Resmi" .
Note that , the " city and phone" fields are null.
We have to update that details (7th row).
To do so, write the command like this in SQL.
When executing we can see ,
The result-set will look like this:
Note: Be careful when updating records. If we had omitted the WHERE clause , all records will be updated!
Notice the WHERE clause in the UPDATE syntax. The WHERE clause specifies which record or records that should be updated.
The created Table is :
Create a Database named "Studysql" and a table named "tbl_biodata"
Right click on the database Studysql and select new query.Then we can write queries as per the requirements.
( Click here to know how created this table )
ID
|
NAME
|
AGE
|
CITY
|
PHONE
|
1
|
Priyada
|
25
|
Cochin
|
1000000001
|
2
|
Mohan
|
30
|
Cochin
|
2000000002
|
3
|
Jaimon Jacob
|
40
|
Vytila
|
3000000003
|
4
|
Sumith
|
24
|
Kottayam
|
4000000004
|
5
|
Shaiju
|
36
|
Thrissur
|
5000000005
|
==================================================================================
In the previous chapter ( SQL "INSERT INTO" Statement ) , we inserted a new row "Resmi" as shown :
Now , we want to update the details of "Resmi" .
Note that , the " city and phone" fields are null.
We have to update that details (7th row).
To do so, write the command like this in SQL.
UPDATE tbl_biodata SET city='Quilon', phone='7000000007' WHERE names='Reshmi' AND age='23'
|
When executing we can see ,
The result-set will look like this:
SQL SELECT Syntax of the above table is :
UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value
SET column1=value, column2=value2,...
WHERE some_column=some_value
Note: Be careful when updating records. If we had omitted the WHERE clause , all records will be updated!
Notice the WHERE clause in the UPDATE syntax. The WHERE clause specifies which record or records that should be updated.
No comments:
Post a Comment