SQL UPDATE Statement –
The ‘update’ statement is used to modified the existing record in a table. In this case notice the WHERE clause. Data are modified where the WHERE clause fulfill the condition. If we don’t provide WHERE clause in UPDATE statement then all data will changed.
UPDATE tablename SET column1=value1, column2=value2,…. WHERE condition;
Bellow the example of UPDATE statement in a table. Record of the table are as-
Following statement is UPDATE the stuCourse ‘Marketing’ to ‘Marketing Course’ of ‘StudentData’ table where Id is 103.
update StudentData set stuCourse ='Marketing Course' where Id=103;
UPDATE multiple record of ‘StudentData’ table. We can also assign value in that field which contain NULL value.
Following statement modified the ‘stuName’ and ‘stuCourse’ of ‘StudentData’ table where Id=104.
update StudentData set stuName='Sundar', stuCourse='B.Tech' where Id=104;
If you forget the use WHERE clause in UPDATE statement then you find the result like as-
update StudentData set stuCourse='Software Trainee';