Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews DB Oracle Interviews:Concepts and ArchitectureData AccessDatabase ArchitectureDatabase ManagementDatabase Security OracleDistributed ProcessingFlexfieldForms ReportsGeneral OracleMemory ManagementMTO-SAP Financial AccountingOCIOracle AOLOracle AROracle Backup RecoveryOracle D2KOracle DatabaseOracle Database DeveloperOracle DB OptimizationOracle DBAOracle DeveloperOracle ETLOracle Forms 3.0Oracle Forms 4.0Oracle GLOracle PL-SQLOracle RMANOracle ScenariosOracle SecurityOracle SQLOracle System ArchitectureOracle Technology Network (OTN)Programmatic ConstructsRAC (Real Application Clusters)SQL Plus
Copyright © 2018. All Rights Reserved
Oracle Database Interview Question:
How To Use Values from Other Tables in UPDATE Statements using Oracle?
Submitted by: AdministratorIf you want to update values in one with values from another table, you can use a subquery in the SET clause. The subquery should return only one row for each row in the update table that matches the WHERE clause. The tutorial exercise below shows a good example:
UPDATE ggl_links SET (notes, created) =
(SELECT last_name, hire_date FROM employees
WHERE employee_id = id)
WHERE id < 110;
3 rows updated.
SELECT * FROM ggl_links WHERE id < 110;
<pre> ID URL NOTES COUNTS CREATED
---- ------------------------ --------- ------- ---------
101 http://www.globalguideline.com Kochhar 999 21-SEP-89
102 http://www.globalguideline.com De Haan 0 13-JAN-93
103 http://www.globalguideline.com Hunold NULL 03-JAN-90</pre>
This statement updated 3 rows with values from the employees table.
Submitted by: Administrator
UPDATE ggl_links SET (notes, created) =
(SELECT last_name, hire_date FROM employees
WHERE employee_id = id)
WHERE id < 110;
3 rows updated.
SELECT * FROM ggl_links WHERE id < 110;
<pre> ID URL NOTES COUNTS CREATED
---- ------------------------ --------- ------- ---------
101 http://www.globalguideline.com Kochhar 999 21-SEP-89
102 http://www.globalguideline.com De Haan 0 13-JAN-93
103 http://www.globalguideline.com Hunold NULL 03-JAN-90</pre>
This statement updated 3 rows with values from the employees table.
Submitted by: Administrator
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.