c# - 如何解决加入问题显示相同的结果
问题描述
我有两张桌子,Customers
和ListTypeData
。我只想加入这两个表。我有CityId
And DistrictId
InCustomers
表。
它给了我同样City
的District
如何修复City
And District
。
SELECT c.[CustomerId]
,c.[Name]
,c.[CompanyName]
,c.[ShopNo]
,list.[Description] AS 'City'
,list.[Description] AS 'District'
FROM [MakkiRuskFaisalabad].[dbo].[Customers] c
JOIN [dbo].[ListTypesData] list ON c.CityId = list.ListTypeDataId ]
解决方案
您需要join
第二ListTypesData
次上桌:
SELECT c.CustomerId
,c.Name
,c.CompanyName
,c.ShopNo
,list.Description AS 'City'
,list2.Description AS 'District'
FROM MakkiRuskFaisalabad.dbo.Customers c
JOIN dbo.ListTypesData list ON c.CityId = list.ListTypeDataId
JOIN dbo.ListTypesData list2 ON c.DistrictId = list2.ListTypeDataId
推荐阅读
- reactjs - 等待一个元素不出现
- c++ - boost numeric_cast 可以抛出的所有异常是什么?
- api - 参数 json_data 的 Zoho Sheet API 问题
- python - 将 (Lambda) 订阅放在 CW Logs 组上
- reactjs - 我无法在 React 中更改表单中的文本
- c# - 大写对象列表c#
- javascript - 如何通过 LibGDX 使用 Facebook Instant Games 排行榜和应用内广告
- android - 我的应用程序遇到此错误无法安装应用程序安装失败
- javascript - 如何在使用地图的反应中将json转换为csv
- android - 即使在基于紧急系统的应用程序的打盹和应用程序待机模式下也需要推送通知支持