Update
To update (modify) data in a table the UPDATE
statement is used. UPDATE
can be used in two ways:
To update specific rows in a table
To update all rows in a table
The basic format of an UPDATE
statement is made up of three parts:
The table to be updated
The column names and their new values
The filter condition that determines which rows should be updated
Update Single Column
Assume customer 1000000005 has no e-mail address on file and now has an address, and so that record needs updating. The following statement performs this update:
If you don't use WHERE
clause, all the rows will be updated.
Update Multiple Columns
Update Under Different Conditions
Cross-table Update: UPDATE JOIN
If we need information in another table when we update values, we need to JOIN the tables.
In the following code, we want to update salary in employees table and we need percentage in merits table.
If join three tables:
Last updated