Oracle Update Column From Another Table Statement
In Oracle, UPDATE
statement allows you to update column from another table. You can use the UPDATE statement to update columns value of a single row, a group of rows, or all rows in a table.
Oracle Update Column From Another Table Syntax
To update column from another table, use the following syntax:
Syntax
UPDATE table_name1
SET field1 = (SELECT newvalue1
FROM table_name2
WHERE table_name2.col1 = table_name1.col1);
Parameters:
tablename: The table name from which you want to update.
field1: Column name to be updated.
Oracle Update Column From Another Table examples
The following Oracle statement to update column first name by fetching the data from "tblCustomerLoan" table.:
Example
UPDATE tblCustomer
SET firstName = (SELECT firstName
FROM tblCustomerLoan
WHERE tblCustomerLoan.custId = tblCustomer.custId) ;
Note:
In the above example, we have updated "tblCustomer" table by fetching the data from "tblCustomerLoan" table.