我有 3 张桌子,一张是用来学习的,另外一张是 Travel 和 Country.Study。
Study
表包含StudyID,StartDate,EndDate,CountryID
并设置StudyID
为primary key
.
Travel
表包含TravelID,StudyID,CountryID,TravelStartDate,TravelEndDate
, TravelID
asPrimary key
和StudyID
as Foreign key
。
Country
表包含CountryID,CountryCode,CountryName, CountryID
as primary key
。
我想变得CountryName
像"CountryCode+' - '+CountryName as CountryName".
我有以下查询:
SELECT
Study.CountryID
,Travel.CountryID
,StartDate
,EndDate
,TravelStartDate,TravelEndDate,
, CountryCode+' - '+CountryName as CountryName,
FROM dbo.Study left join dbo.Countries
on
Study.CountryID=Countries.CountryID
left join Travel
on
Travel.StudyID=Study.StudyID
我想显示CountryName
forTravel
和Study
. 如何显示一个国家旅行和一个学习?