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

  • SEARCH
  • Home
  • 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 343815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:55:57+00:00 2026-05-12T10:55:57+00:00

I need to merge two SELECT statements. There are two tables in my database,

  • 0

I need to merge two SELECT statements.

There are two tables in my database, where table A consists of two fields; Type and Counter. Table B consists of two fields; Source and destination.

Table A has three items; 
                   { 1, 5000 }, { 2, 10000 } and { 3, 15000 }. ({Type, Counter})
Table B has two items; 
                   { 5000, 10000 } and { 10000, 150000 }. ({Source, Destination})

That is, table B’s values consist of data from table A.

The data I have available for my query are Type in table A (1, 2 and 3).

The end result of a query (the one I’m after) to the database should be one item; { 5000, 10000, 15000 }, where columns should read {Source, Middle, Destination}, respectively. However, I’ve been unable to create a query that can appear in such format.

I am able to get the data using an INNER JOIN, where the result appear as two items; { 5000, 10000 } and { 10000, 15000 }. (Not simply the content of table B that is, if the tables would consist of other items, as well.)

(There’s obviously far more items in both tables than I’ve displayed above.)

So, how can I write the SQL query to make my result appear as { 5000, 10000, 15000 } (with appropriate column names)?

  • 1 1 Answer
  • 1 View
  • 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-12T10:55:58+00:00Added an answer on May 12, 2026 at 10:55 am

    From your question, you don’t have any use or need for table A – you are simply joining Table B to itself on Source = Destination.

    Your query should be

    SELECT a.Source, a.Destination, b.Destination
    FROM [Table B] as a INNER JOIN [Table B] as b
    ON a.Destination = b.Source
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two columns in a table. I need to merge these two columns
Very simplified, I have two tables Source and Target. declare @Source table (SourceID int
I have two tables with hierarchyid fields, one of which is a staging table
I have a situation where I need to merge two product tables into one
I need to merge two bitmaps to use the resulting bitmap as a mask.
I need to merge any missing rows in a production mysql database from a
I have multiple tables that need to be merged into one. SELECT name, SUM(money)
If I run the two statements in batch will they return one table to
I'm looking for a query to select rows from two different tables, keeping the
Here’s a problem I’ve really been struggling with. I need to merge two sorted

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.