Query in PL/SQL

I have 2 queries that I need to combine into 1 query. I need to bring back both datasets as If I ran them separately and Merged them together. Im thinking I could just do an OUTER JOIN but the guy Im working with suggested a UNION ALL and Im not sure which one is easier or better to use. Both queries params come from the same table Im looping through

Here are the 2 queries

Select ENDORSE_WC290303.NAME_OF_CLIENT From ENDORSE
INNER JOIN ENDORSE_WC290303 ON ENDORSE_WC290303.ENDORSE_ID = ENDORSE.ENDORSE_ID
WHERE ENDORSE.CARRID = :pCARRID AND ENDORSE.POLNBR = :pPOLNBR AND ENDORSE.COV_EFFDT = :pCOV_EFFDT AND ENDORSE.ENDORSE_CD_NBR = '123'

Select INSURED_NAME, i.COV_EFFDT, NAME_EXPDT, UI_NBR from INSURED_ENTITY where CVG_ID= :pCVG_ID AND POLNBR= :pPOLNBR AND COV_EFFDT = :pCOV_EFFDT ORDER BY COV_NAME_SEQ ASC

I need to Join the 2 tables and get back both of the result sets combined....Whats the best way to do this?
jknj72Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
If you can write a join that returns the correct results, generate an explain plan for yours and the union all and see which one is better.

Off the top of my head, I'm not sure how you would write a join to return both sets of data but it is late in the week for me...

I would probably do the union all.
0
jknj72Author Commented:
Well now that Im thinking about it, I want them almost run separate and merged some how and Im not sure I can get that with the join?
I need 1 dataset on top of the other almost? Does that even makes sense? Long week!!
0
slightwv (䄆 Netminder) Commented:
>>Im not sure I can get that with the join?

Me neither...

>>I need 1 dataset on top of the other almost?

To me, that is a "UNION ALL".
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

jknj72Author Commented:
WHAT ABOUT INTERSECT?
0
slightwv (䄆 Netminder) Commented:
Intersect returns the rows both sets have in common.

Given
set A:  1,2,3,4,5
set B: 3,5

intersect returns 3,5
union returns 1,2,3,4,5
union all returns 1,2,3,4,5,3,5
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jknj72Author Commented:
I actually knew that just needed it explained to me again!!
Union All it is....
Thanks man...

Have a good weekend!!
0
jknj72Author Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.