Update data in table using SQL

Update SQL statement is also very important in DML (data manipulation language). We can update selective or all records from table by using update SQL statement. By putting condition we can update partial data from a table which satisfies the condition. And if we need to update all the record then we can run update SQL statement without any condition. In our update statement we need to specify fields also which's value need to be updated 1. Update statement with condition: By adding where condition in update statement we can update partial records from a table which matches with the condition. Example is mentioned below: Example


UPDATE student_info SET first_name='Ram', last_name='Singh' WHERE id='1';

UPDATE student_info SET admission_year='2017' WHERE class_name='3rd';
2. Update statement without condition: With this approach we can update all the records present in our table. We do not need to put any condition with our update SQL statement. Example is mentioned below:

Example


UPDATE student_info SET school_name='ABC Sample School';