【发布时间】:2018-01-05 23:15:42
【问题描述】:
我有两个表,首先将 ID 存储到公司名称 公司(ID varchar2(4),CompanyName varchar2(20))
1001 - Company1
1002 - Company2
1003 - Company3
1004 - Company4
另一个表 SellerBuyer 存储哪个公司向哪个公司销售 每个卖家或买家都可以为空 例如
(1001,null) 1001 has no buyer
(1002,1003) 1002 is selling to 1003
(1002,1004) 1002 is selling to 1004
(1003,1004) 1003 is selling to 1004
(null,1004) 1004 is also buying from unknown seller.
请帮助我使用 SQL,它会根据存储在表 Companies、SellerBuyer 中的数据打印公司名称,如下所示
(Company1,null)
(Company2,Company3)
(Company2,Company4)
(Company3,Company4)
(null,Company4)
【问题讨论】:
标签: sql join database-design