答案 0 :(得分:1)
使用简单的联接即可实现:
select s.name,c.name,ci.name from @state s
join @Country c
on s.countryid = c.id
join @city Ci on ci.stateid=s.ID
答案 1 :(得分:0)
简单的左联接将为您工作:
SELECT
S.Name AS State,
C.Name AS Country,
CT.Name AS City
FROM
State S
LEFT JOIN Country C
ON C.Id = S.Country_Id
LEFT JOIN City CT
ON CT.StateId = S.Id
答案 2 :(得分:0)
使用join可以实现它。
select ,b.name a.name,c.name Country as a inner join State as b on a.id=b.CountryID inner join City as c on c.StateId=b.id