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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Combine results of 2 queries into 1 result row

920375Feb 27 2012 — edited Feb 27 2012
Ok so I have 2 queries from 2 different tables, and I am combining them into one query as follows:


select * from
(select col1 from tblA where col1 = 'val1') a,
(select col2 from tblB where col2 = 'val2') b


and so the results return as (I am expecting only 1 result from each query):

col1 ... col2
=== ===
aa ... 11

The problem is, that when either of the subqueries returns no results, the entire query returns no results. I want a result row even if one query returns no results, as such:


col1 ... col2
=== ===
aa ... NULL


OR


col1 ... col2
=== ===
NULL ... 11


I have looked into the different types of joins and unions, but have had trouble finding anything simple that returns only one row - any suggestions?

Edited by: 917372 on Feb 27, 2012 4:28 PM

Edited by: 917372 on Feb 27, 2012 4:28 PM

Edited by: 917372 on Feb 27, 2012 4:29 PM

Edited by: 917372 on Feb 27, 2012 4:31 PM
This post has been answered by Frank Kulash on Feb 27 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 26 2012
Added on Feb 27 2012
3 comments
11,302 views