-
SQL - JOIN using UNION ?? UNION using JOIN ?? with example!
I was asked this question during one of my interviews. Can you do JOIN using UNION keyword? Can you do UNION using JOIN keyword?
Can you give me an example of how to do this if possible?
-
What was your answer?
As you may remember UNION is used to merge two datasets which columns have identical data types while JOIN is used to filter datasets.
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
-
I could not answer it.. I think its possible!
To clarify
1. I should get same output as JOIN without using JOIN keyword, but using UNION Keyword?
2. I should get same output as UNION without using UNION keyword, but using JOIN Keyword?
-
Originally Posted by user811568
I could not answer it.. I think its possible!
To clarify
1. I should get same output as JOIN without using JOIN keyword, but using UNION Keyword?
2. I should get same output as UNION without using UNION keyword, but using JOIN Keyword?
Okay. Show us how, try this specs...
-- TABLE_A
A_ID NUMBER NOT NULL
A_CODE NUMBER
-- TABLE_B
B_ID NUMBER NOT NULL
B_TEXT VARCHAR2(10)
-- BUSINESS REQUIREMENT
Return all (B_ID, B_TEXT) rows which B_ID matches A_ID where A_CODE = 10
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
-
This is very easy question and a good one for job interview
Originally Posted by user811568
I was asked this question during one of my interviews. Can you do JOIN using UNION keyword? Can you do UNION using JOIN keyword?
Can you give me an example of how to do this if possible?
This is very easy question and a good one for job interview. It help fikter children that do not realy understand the operation of JOIN and UNION :-)
you can look at this article at Microsoft Technet site, for a full exampls (UNION using JOIN and vice versa)
http://social.technet.microsoft.com/...play-time.aspx
Hope this will help you :-)
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|