Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6363653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:03:52+00:00 2026-05-25T00:03:52+00:00

Please review my sample queries (given below), and let me know which query would

  • 0

Please review my sample queries (given below), and let me know which query would perform better and why.

Approach 1:

select team_id,grp_name,grp_desc from
(
select distinct team_id,grp_name,grp_desc from team_table tt where .....
UNION
select team_id,grp_name,grp_desc from sec_team_table stt where ....
UNION
select team_id,grp_name,grp_desc from ter_team_table ttt where...
)

Approach 2:

select distinct team_id,grp_name,grp_desc from team_table tt where .....
UNION
select team_id,grp_name,grp_desc from sec_team_table stt where ....
UNION
select team_id,grp_name,grp_desc from ter_team_table ttt where...

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:03:53+00:00Added an answer on May 25, 2026 at 12:03 am

    In most cases, they will be equivalent, because there is no transformation in the outer query – the optimizer will handle that silently.

    I would recommend you ensure that you really do need to use UNION instead of UNION ALL.

    In fact, combining UNION and the DISTINCT used in your first part of the UNION is redundant, because the UNION is going to ensure that duplicates are removed from the final set (both within sub-parts of the UNION and across parts of the UNION).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please review my brief example code below and tell me if there is better,
Please excuse the vague title. If anyone has a suggestion, please let me know!
Below is my query which is in Storedprocedure(SQL Server 2008) will return list of
Please, move this question to Code Review -area . It is better suited there
I would like you to review on my sample Wordpress theme index.php code. <?php
Please read the whole question. I'm not looking for an approach to managing multi-lingual
i am trying to imitate the sample given with using autofac, but constantly getting
Please review my code and give me your advise on this: XML file: content.xml
Please review the fiddle here for an example: http://jsfiddle.net/TKJsc/1/ Basically i'm trying to make
I'm displaying errors on my form with the use of <%= Html.ValidationSummary(Please review the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.