【发布时间】:2017-01-25 17:36:31
【问题描述】:
我需要选择客户和供应商居住的所有独特的英国城市,从 A 到 Z 排序
我有两张表:Customers 和 Suppliers。它们都有 City 和 Country 列。
这是我的要求:
select distinct Customers.City, Suppliers.City, Customers.Country, Suppliers.Country
from Customers
join Suppliers
on Customers.Country = Suppliers.Country
where Customers.Country like "UK";
结果我得到 4 列:City、City、Country、Country。
我哪里错了?
【问题讨论】:
-
您得到 4 列,因为您要求 4 列。我不清楚你想要什么。 “向我显示在同一城市和国家/地区也有客户的供应商所在的城市/国家/地区?”
-
你不想要一个 JOIN 你想要一个 UNION
-
我需要两个不同表格中的独特英国城市。