DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: SQL - JOIN using UNION ?? UNION using JOIN ?? with example!

  1. #1
    Join Date
    Jul 2011
    Posts
    2

    Question 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?

  2. #2
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    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.

  3. #3
    Join Date
    Jul 2011
    Posts
    2

    Unhappy

    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?

  4. #4
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    Quote Originally Posted by user811568 View Post
    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.

  5. #5
    Join Date
    Oct 2013
    Posts
    1

    This is very easy question and a good one for job interview

    Quote Originally Posted by user811568 View Post
    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
  •  


Click Here to Expand Forum to Full Width