内部加入不显示所有结果

时间:2015-01-24 11:49:44

标签: sql-server join

有人可以帮助解决查询问题: 我有2个表具有公共字段CheckID。 当我运行如下的Select语句时,我得到2行的正确结果,但是当我使用内部联接时,它只返回一行。 我正在尝试从MS Access转换到SQL Server,所以我在这里遗漏了一些东西? 任何帮助高度赞赏。 这些表目前包含这两行

Select CheckID from table1 where CheckID = 723 or CheckID = 322 'returns 2 rows
Select CheckID from table2 where CheckID = 723 or CheckID = 322 'returns 2 rows

Select CheckID from table1 inner join table2 
on table1.CheckID = table2.CheckID ' returns only 1 row

1 个答案:

答案 0 :(得分:-1)

您只从table1中选择CheckID。

请出于此目的尝试:

Select CheckID.table1, CheckID.table2 from table1 inner join table2 
where table1.CheckID = 123 or table2.CheckID = 345;
相关问题