我将7列合并为一列,所有地址均合并为一列。最初,位置,城市,州和国家/地区会在其对应的表中存储其显示值的代码。因此,我加入了下面的所有查询。
SELECT CustomerName, CustomerId, ContactPerson,
((BFlatNo +','+ BPremises +','+ BStreet +','+ BArea) + ',' +
(select LocationName from Location where LocationId = Customer.Location) + ',' +
(select CityName from City where CityId = Customer.City) + ',' +
(select StateName from State where StateId = Customer.State) + ',' +
(select CountryName from Country where CountryId = Customer.Country) + ',' +
(BMobileNumber) ) AS BillingAddress,
((DFlatNo +','+ DPremises +','+ DStreet +','+ DArea) + ',' +
(select LocationName from Location where LocationId = Customer.Location) + ',' +
(select CityName from City where CityId = Customer.City) + ',' +
(select StateName from State where StateId = Customer.State) + ',' +
(select CountryName from Country where CountryId = Customer.Country) + ',' +
(DPhone) ) AS DeliveryAddress
FROM Customer
WHERE Customer.CustomerId = 11;
在MS Access中预览数据表视图时,它会询问Customer.Location,Customer.City,Customer.State和Customer.Country,然后显示CustomerId = 11的结果
单击数据表视图时,我需要显示客户详细信息。实际上在客户表位置中,其字段名称是BLocation,城市是BCity,州是BState,国家/地区是BCountry,但是如果我给Select LocationName from Location where LocationId=Customer.BLocation
它显示语法错误。
帮我解决这个问题?
谢谢你们,这段代码工作正常
SELECT CustomerName, CustomerId, ContactPerson,
((BFlatNo +','+ BPremises +','+ BStreet +','+ BArea)+','+
(select LocationName from Location where LocationId=Customer.BLocation)+','+
(select CityName from City where CityId=Customer.BCity)+','+
(select StateName from State where StateId=Customer.BState)+','+
(select CountryName from Country where CountryId=Customer.BCountry)+','+ (BMobileNumber)) AS BillingAddress,
((DFlatNo +','+ DPremises +','+ DStreet +','+ DArea)+','+
(select LocationName from Location where LocationId=Customer.DLocateion)+','+
(select CityName from City where CityId=Customer.DCity)+','+
(select StateName from State where StateId=Customer.DState)+','+
(select CountryName from Country where CountryId=Customer.DCountry)+','+ (DPhone)) AS DeliveryAddress
FROM Customer;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句