Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to get data from multiple tables

Author  Topic 

krishmallela
Starting Member

2 Posts

Posted - 2011-11-29 : 00:09:23
Hi All,

I have two tem tables like below

Table name1 - #TempOld
ID ChangesetID
34 13
35 13


Table name2 - #TempNew
ID ChangesetID
53 22
54 22



Now i want to display the data like below
oldID NewID
34 53
35 54

Could you please help me how can i do this?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-11-29 : 00:12:16
what is the relationship between these 2 tables ?

How do you relate ID 34 to 53 ? based on ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-11-29 : 03:40:19
bsed on your output, it looks like this, but it makes no sense at all!


SELECT t1.ID,t2.ID
FROM (SELECT ROW_NUMBER() OVER (ORDER BY ID) AS Rn,* FROM #TempOld
)t1
JOIN (SELECT ROW_NUMBER() OVER (ORDER BY ID) AS Rn,* FROM #TempNew
)t2
ON t2.Rn=t1.Rn


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -