Oracle does not have the update from syntax, which enables the same functionality in two ways:
1: Subquery update A SET a.name= (SELECT b.name from B WHERE b.id=a.id), this query will be based on the specific situation to see if the following are flexible
(1) Single column
UPDATE A
SET a.name= (SELECT b.name from B WHERE b.id=a.id)
WHERE a.id in (SELECT ID from B);
(2) Multiple columns
UPDATE Order_rollup
SET (Qty,price) = (SELECT SUM (qty), SUM (price) from Order_lines WHERE customer_id= ' KOHL ')
WHERE cust_id= ' KOHL ' and order_period=to_date (' 01-oct-2000 ')
2: Use a view to do
UPDATE (SELECT a.name aname,b . NAME bname from A,b WHERE a.id=b.id)
SET aname=bname;
Example:
UPDATE TableA a
SET a.fieldforupdate = (SELECT b.fieldsource from TableB b WHERE A.keyfield = B.keyfi ELD)
where EXISTS (SELECT b.fieldsource from TableB b WHERE a.keyfield = B.keyfield)
has three points to note:
1. For a given a. Keyfield value, SELECT b.fieldsource from TableB b WHERE A.keyfield = B.keyfield value can only be a unique value, not multi-valued.
2. In most cases, the last side of the WHERE EXISTS clause is important, otherwise you will get the wrong result. Because if you do not add this sentence, all records that do not match the primary table will be updated to NULL.
3. Restrictions on view updates:
If the view is based on a connection of multiple tables, the ability to record the user update view is limited. The base table of the view cannot be updated unless the update involves only one table and the View column contains the entire primary key of the table being updated.