我有一份供应国家/地区名单的供应商名单。例如:
供应商 A 供应给:
以及另一份供应商及其供应商工厂清单 例如:
供应商 A 制造:
如何构建(供应商、国家、工厂)的所有可能组合的列表(按行)?我有超过 10.000 个供应商。例如,对于供应商 A:
有人可以帮我解决这个问题吗?我已经尝试使用 Excel 和 Access 进行了数周的研究。
使用 SQL Server,因为我没有安装 Access,希望这足够通用,对你有用:
CREATE TABLE SupplierCountry
(
SupplierName varchar(50) NOT NULL,
CountryName varchar(50) NOT NULL
);
INSERT SupplierCountry
(SupplierName, CountryName)
VALUES
('Supplier A', 'USA'),
('Supplier A', 'France'),
('Supplier A', 'China');
Run Code Online (Sandbox Code Playgroud)
??????????????????????????????
? SupplierName ? CountryName ?
??????????????????????????????
? Supplier A ? USA ?
? Supplier A ? France ?
? Supplier A ? China ?
??????????????????????????????
Run Code Online (Sandbox Code Playgroud)
CREATE TABLE SupplierFactory
(
SupplierName varchar(50) NOT NULL,
CountryName varchar(50) NOT NULL
);
INSERT SupplierFactory
(SupplierName, CountryName)
VALUES
('Supplier A', 'UK'),
('Supplier A', 'Germany');
??????????????????????????????
? SupplierName ? CountryName ?
??????????????????????????????
? Supplier A ? UK ?
? Supplier A ? Germany ?
??????????????????????????????
Run Code Online (Sandbox Code Playgroud)
SELECT
SC.SupplierName AS Supplier,
SC.CountryName AS SupplyCountry,
SF.CountryName AS FactoryCountry
FROM SupplierCountry AS SC
JOIN SupplierFactory AS SF
ON SF.SupplierName = SC.SupplierName;
Run Code Online (Sandbox Code Playgroud)
???????????????????????????????????????????????
? Supplier ? SupplyCountry ? FactoryCountry ?
???????????????????????????????????????????????
? Supplier A ? USA ? UK ?
? Supplier A ? France ? UK ?
? Supplier A ? China ? UK ?
? Supplier A ? USA ? Germany ?
? Supplier A ? France ? Germany ?
? Supplier A ? China ? Germany ?
???????????????????????????????????????????????
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5007 次 |
最近记录: |