UPDATE Statement in SQL

              UPDATE Statement in SQL

1. Create Table

CREATE TABLE Employee
(
   Id int,
   Name varchar(20),
   City varchar(20)
);

2. Insert Values in Table.

insert into Employee values('3','Arjit','Jiaganj')

3.Print Table

select * from Employee

                                     


           The UPDATE statement is used to modify data in a  database table.

    UPDATE Table


  The following SQL updates the first Employee (Id = 1) with a new Name and a new City.

UPDATE Employee SET Name = 'Sonu' , City= 'Haryana' Where Id = 1;

 UPDATE Multiple Records


Before Update



It is the WHERE clause that determines how many records will be updated.
   
     The following SQL statement will update the Name to "Kishore" for all records where City is "Haryana":

              UPDATE Employee
              SET Name='Kishore'
              WHERE City='Haryana';
After Update



    

Contact us for software training, education or development










 

Post a Comment

0 Comments