Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Query to return the value in same column from two different tables

user11164339Jul 30 2012 — edited Jul 30 2012
Hi All - I had the following scenario & i need the inputs from you.

There are two tables say xx1 and xx2 which has the same column names as id,name


Scenario1:

xx1 has the data like --No records
xx2 has the data like --1,xyz

select NVL(xx1.name,xx2.name) name from xx1,xx2 where xx2.id(+)=xx1.id --This gives me xyz

Scenario2:

xx1 has the data like --1,
xx2 has the data like --1,xyz

select NVL(xx1.name,xx2.name) name from xx1,xx2 where xx2.id(+)=xx1.id --This gives me xyz
In this scenario,as the data is available in both the tables.Even the name in xx1 table is null.I want that value from xx1 instead of xyz.

If xx1 & xx2 has the records for the same id ,then the name should come from xx1.Even though the name is null i have to get the value as null.

Based on the above two scenarios,i have to store the value in the same column .

Edited by: user11164339 on Jul 30, 2012 3:44 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 27 2012
Added on Jul 30 2012
9 comments
1,300 views