I want to combine 2 tables into one. Say I have:
Table 1
ID Name 1 A 2 B 3 C
Table2
ID Name 4 D 5 E 6 F
I want to make Table3
Name1 Name2 A D B E C F
How to do this in SQL Server? Any help is appreciated.
WITH t1 AS ( SELECT a.*, ROW_NUMBER() OVER (ORDER BY id) AS rn FROM table1 a ), t2 AS ( SELECT a.*, ROW_NUMBER() OVER (ORDER BY id) AS rn FROM table2 a ) SELECT t1.name, t2.name FROM t1 JOIN t2 ON t1.rn = t2.rn
select t1.Name Name1, t2.Name Name2 from Table1 t1, table2 t2 where t1.ID = t2.ID
OR
select t1.Name Name1, t2.Name Name2 from Table1 t1 join table2 t2 on t1.ID = t2.ID
Source: https://habr.com/ru/post/1709968/More articles:How to use Red5 with Asp.net - asp.netHow to stop the appearance of the command line in a Win32 C application? - cSilverlight onerror callback processing - error-handlingВ рабочей области собрания все программные пункты из списка программно - sharepointHow can I emphasize part of the text, for example, iPhone SMS? - iphoneWhen class B inherits from class A, it must be, "class B is class A"? - oopIs it possible to group form elements in "p"? - htmlWhat is the best resource grouping strategy in a .NET application - c #Displaying analytical results in MATLAB GUI - user-interfaceHow can I sign a digit and trust a message in a distributed program that I know can be programmed with feedback? - encryptionAll Articles