C# 如何解决连接问题显示相同的结果
我有两个表,C# 如何解决连接问题显示相同的结果,c#,sql,C#,Sql,我有两个表,客户和列表类型数据。我只想把这两张桌子连接起来。 我在Customers表中有CityId和DistrictId 它给了我城市和地区相同的修复方法 对于城市和地区 SELECT c.[CustomerId] ,c.[Name] ,c.[CompanyName] ,c.[ShopNo] ,list.[Description] AS 'City' ,list.[Description] AS 'Distr
客户
和列表类型数据
。我只想把这两张桌子连接起来。
我在Customers
表中有CityId
和DistrictId
它给了我城市
和地区
相同的修复方法
对于城市
和地区
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 ]
您需要再次
加入列表类型数据表:
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
您需要再次加入列表类型数据表:
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