小编典典

SQL从多个表中选择不同的值

sql

所以这是我的设置,我有2个具有以下(简化)模式的旧表和新表

Old
[ManName]
[ManNumber]

New
[Manager_Name]
[Manager_Number]

我正在寻找一种SQL查询,该查询返回以下内容,但在1个查询中包含4列,而不是每个2列包含2个查询

select distinct manname, mannumber from OLD 
select distinct Manager_Name, Manager_Number from NEW

因此,我理想的结果集将包含4列:

ManName ManNumber Manager_Name Manager Number

谢谢!


阅读 186

收藏
2021-04-28

共1个答案

小编典典

您是否尝试过JOIN语句:

select distinct * 
from old a join new b on a.ManName = b. Manager_Name and a. ManNumber = b. Manager_Number
2021-04-28