0

提前感谢您的帮助

我在 sql server 中有 Tow 表,我想将它们联合起来而不将 Rows 混合为 Flowing:

T1 是

   ID    Name

   1     john
   2     Lol

T2 是

  ID    Name

  1     Normi
  2     CRI

如果我确实选择了 LIKE THAT:从 T1 中选择 Id,Name Union select Id,Name from T2 结果将是 Like

 ID    Name
 1     john
 1     Normi
 2     Lol
 2     CRI

但对我来说,我想要结果喜欢

   ID    Name
   1     john
   2     Lol
   1     Normi
   2     CRI

请帮忙再次谢谢

4

1 回答 1

3
SELECT a.id, a.Name
FROM 
(select Id,Name, 1 as num from T1 Union select Id,Name, 2 as num from T2)a
ORDER BY a.num,a.Id
于 2012-04-13T16:58:50.400 回答