Saturday, 28 July 2018

Oracle update from select: 3 ways to do update from Select Statement

Oracle update from select


In this post , I will share the sql script , which will help to update the table from the Select statement. Oracle provides the option by which we can update the table specific columns through sql query. The main important thing in the oracle update from select is this , we dont need to hardcode or fix the value to the column of the table during update but with the help of select we can put value to the update as per our specific condition.


Oracle update from select: 3 ways to do update from Select Statement


As above these are the two table and supplier id is the common column between these two tables. Here i am using the example of Oracle update from select.

UPDATE XX_SUPPLIER_INVOICE_TBL A1
SET Supplier_Name=(SELECT Supplier_Name FROM XX_SUPPLIER_TABLE WHERE SUPPLIER_ID=A1.SUPPLIER_ID);


UPDATE XX_SUPPLIER_INVOICE_TBL A1
SET (A1.Supplier_Name,A1.Supplier_Phone)=(SELECT A2.Supplier_Name,A2.Supplier_Phone FROM XX_SUPPLIER_TABLE A2 WHERE A2.SUPPLIER_ID=A1.SUPPLIER_ID);

0 comments:

Post a Comment

Contact us for any Collaboration, Project Support & On Job Support Work

Name

Email *

Message *