Learn about using UPDATE statement in SQL. As the name suggests UPDATE statement is used to update the data rows in a table. The UPDATE statement can update one or multiple column values in single SQL statement. WHERE clause is used to specify the data row to be updated. UPDATE statement without WHERE clause will update all the data rows in the table. Any existing data rows or records in target table remain unaffected.
Here are the examples UPDATE statements,
UPDATE tablename SET column1 = newvalue;
UPDATE tablename SET column1 = newvalue1, column2 = newvalue2 WHERE columnid = 3;
Select the "school" database, "USE school;"
Run a simple SQL statement to display all the data rows in students table using SQL statement, "SELECT * FROM students;"
Here in this result set, take a look at studentid 1. Suppose we have accidentally added this student record under class first instead of second. And now we are going to update this row to change the class value from 'First' to 'Second'.
We will use the SQL statement, "UPDATE students SET class = 'Second' WHERE studentid = 1;"
Press enter to execute the statement and display all the data rows in 'students' table, "SELECT * FROM students;"
And sure enough the class value for studentid 1 is changed from 'First' to 'Second'.
Check out the whole playlist of SQL Tutorials or Individual video from the following links,
SQL Tutorial for Beginners. Introduction to SQL Basics
1.Learn What is SQL? Introduction to SQL
2.Learn How to Install MySQL Database Server on Windows Operating System
3.Learn What is Database? How to Create and Show Databases using SQL
4.Learn How to Select and Use Existing Database using SQL
5.Learn How to Delete or Remove Database using SQL
6.Learn What is Database Table? How to Create a Database Table using SQL?
7.Learn How to Modify or Update Database Table using SQL
8.Learn How to Delete or Remove Database Table using SQL
9.Learn How to Add Data Rows in a Table using SQL
10.Learn How to Use INSERT INTO SELECT Statement in SQL
11.Learn How to Update Data Rows using Update Statement in SQL
12.Learn How to Delete Data Rows using Delete Statement in SQL
Subscribe to my channel: https://www.youtube.com/channel/UCvrq9OowoORTV5Gs_jpADhw