如何在串联列SQL上联接

我有两个桌子,

段文件

INVNO  SEGNO  COLUMNS
00001  1      Blah
00001  2      Blah
00001  3      Blah
00002  1      Blah
00002  2      Blah
00003  1      Blah

和详细信息文件

INVNO  SEGNO   COLUMNS
00001  1       Blah
00001  2       Blah
00001  2       Blah
00002  1       Blah
00003  1       Blah
00003  1       Blah

因此,我需要两个表中的所有内容。最佳做法是什么?我最初的想法是有人在两个表的连接列上进行联接(连接INVONO和SEGNO)。我不知道该怎么做,但这是我最好的猜测。任何帮助都将受到赞赏。

tqh123456 回答:如何在串联列SQL上联接

像这样加入。 我会列出所有列,而不使用通配符。 但是您没有告诉我们这些专栏。

select s.invno,s.segno,s.*,d.*
from segment s
join details d on s.invno = d.invno and s.segno = d.segno
,

您可以加入两列:

select . . .   -- your columns go here
from segments s join
     details d
     on d.invno = s.invno and d.segno = s.segno
,

使用多列。

select s.invno,d.*
from segments s join
     details d
     on d.invno = s.invno AND d.segno = s.segno
本文链接:https://www.f2er.com/3163814.html

大家都在问