SQL Update Query:
The SQL UPDATE statement is used to update records in a table.
SQL UPDATE Query Syntax:
UPDATE table_name SET column_1=value_1,column_2=value_2,...column_n=value_n WHERE some_column=some_value;
Here the WHERE clause specifies which record should be updated. If we didn’t mention WHERE clause then all the records will be updated.
Following statement would update the value in the column name ‘Balls‘ of ‘SCOREBOARD’ table to ‘25‘ where the ‘Playername’ is equal to ‘Dravid‘.
UPDATE SCOREBOARD SET Balls=25 WHERE Playername='Dravid';
In the above query, we have specified WHERE Playername=’Dravid’. So only the data related to Playername=’Dravid’ gets updated. If not, all records will be updated.
In the above screenshot, value in the Balls column related to Playername Dravid is 30 based on first SELECT Query and the value in the Balls column related to the same Playername is 25 based on the second SELECT Query.
In the next tutorial, we will see How To DELETE Data in a Table in SQL
Check out the complete SQL Tutorial by clicking on below link: