构造一个SQL查询,该查询将列出所有没有与之关联的客户的地址的街道、城市、州、ZipCode。
我不明白这个问题要求我做什么。我可以选择街道、城市、州和ZipCode。
我正在使用Server 2012
我有两张桌子:顾客(CustomerID (PK),CustomerName,CustomerAddressID(FK))地址(AddressID (PK),街道,城市,州,ZipCode)


发布于 2015-11-08 23:14:38
它要求您查找所有没有关联客户的地址(因此他们可能有AddressId,但没有关联的CustomerAddressId )。要获得这个结果,您可以使用以下方法:
SELECT a.*
FROM Address a
LEFT JOIN Customer c
on c.CustomerAddressId = a.AddressId
WHERE c.CustomerId IS NULLhttps://stackoverflow.com/questions/33600135
复制相似问题