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 3964832
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:22:56+00:00 2026-05-20T03:22:56+00:00

What I am trying to accomplish is to get the ID column from @temp2

  • 0

What I am trying to accomplish is to get the ID column from @temp2 to correspond to both intA and intB columns from @temp1
The end result output I would hope to see would look something like:

intA    intB    'asset1'    'asset2'    'name1' 'name2'

1   1   108 108 Cash    Cash

1   2   108 109 Cash    Commodities

1   3   108 138 Cash    Stock
.
.
.

2   5   109 111 Commodities Equity

Here is some sample data I am working with:

declare @temp1 table
(
    intA    int,
    intB    int
)
insert @temp1
select 1,1 union all
select 1,2 union all
select 1,3 union all
select 1,4 union all
select 1,5 union all
select 2,1 union all
select 2,2 union all
select 2,3 union all
select 2,4 union all
select 2,5

select * from @temp1
declare @temp2 table
(
    oneup   int,
    id  int,
    name    varchar(30)
)
insert @temp2
select 1,108,'Cash' union all
select 2,109,'Commodities' union all
select 3,138,'Stock' union all
select 4,110,'Bonds' union all
select 5,111,'Equity'

select * from @temp2

select t1.*,t2.* from @temp1 t1
inner join @temp2 t2
on t1.intA = t2.oneup

I can’t get the join to work right to give me an output like I expect.
Using SQL2008

thanks for any assistance!

  • 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-20T03:22:56+00:00Added an answer on May 20, 2026 at 3:22 am

    You need to join to @temp2 twice, once for intA and once for intB.

    select t1.intA, t1.intB, 
           t2a.id as asset1,  t2b.id as asset2, 
           t2a.name as name1, t2b.name as name2
        from @temp1 t1
            inner join @temp2 t2a
                on t1.intA = t2a.oneup
            inner join @temp2 t2b
                on t1.intB = t2b.oneup
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What I am trying to accomplish: HTTP GET the contents of a site (say
Hi here's what I'm trying to accomplish. I have a div with ID=columns, in
First of all here what i'm trying to accomplish: Get the sum of etp_product.price
I'm trying to update a column in one table1 ('keyword') with data (from 'data')
I am trying to get a single column layout to work. The page has
What I am trying to accomplish to to get financial data in my Flex
Im trying to accomplish something which may seem a bit convoluted but would be
I'm trying to accomplish a simple thing. I have a 2 levels menu with
I'm trying to accomplish something very, very similar to the below picture with CSS3
I'm trying to accomplish this but I've got no clue about getting a GWT

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.