The SQL UPDATE Statement
The UPDATE
statement is used to modify the existing records in a table.
UPDATE Syntax
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;Note: Be careful when updating records in a table! Notice the WHERE
clause in the UPDATE
statement. The WHERE
clause specifies which record(s) that should be updated. If you omit the WHERE
clause, all records in the table will be updated!
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE condition;
Note: Be careful when updating records in a table! Notice the WHERE
clause in the UPDATE
statement. The WHERE
clause specifies which record(s) that should be updated. If you omit the WHERE
clause, all records in the table will be updated!
SQL UPDATE
The SQL commands (UPDATE and DELETE) are used to modify the data that is already in the database. The SQL DELETE command uses a WHERE clause.
SQL UPDATE statement is used to change the data of the records held by tables. Which rows is to be update, it is decided by a condition. To specify condition, we use WHERE clause.
The UPDATE statement can be written in following form:
Let's see the Syntax
Let's take an example: here we are going to update an entry in the source table.
SQL statement:
Source Table:
Student_Id | FirstName | LastName | User_Name |
---|---|---|---|
1 | Ada | Sharma | sharmili |
2 | Rahul | Maurya | sofamous |
3 | James | Walker | jonny |
0 Comments