3 回答
TA贡献1784条经验 获得超9个赞
您可以执行以下操作(我猜对于表字段等)
SELECT s.studentname
, s.studentid
, s.studentdesc
, h.hallname
FROM students s
INNER JOIN hallprefs hp
on s.studentid = hp.studentid
INNER JOIN halls h
on hp.hallid = h.hallid
根据您对多个大厅的要求,您可以这样做。您只需多次加入您的霍尔表,每个房间的首选项:
SELECT s.StudentID
, s.FName
, s.LName
, s.Gender
, s.BirthDate
, s.Email
, r.HallPref1
, h1.hallName as Pref1HallName
, r.HallPref2
, h2.hallName as Pref2HallName
, r.HallPref3
, h3.hallName as Pref3HallName
FROM dbo.StudentSignUp AS s
INNER JOIN RoomSignUp.dbo.Incoming_Applications_Current AS r
ON s.StudentID = r.StudentID
INNER JOIN HallData.dbo.Halls AS h1
ON r.HallPref1 = h1.HallID
INNER JOIN HallData.dbo.Halls AS h2
ON r.HallPref2 = h2.HallID
INNER JOIN HallData.dbo.Halls AS h3
ON r.HallPref3 = h3.HallID
TA贡献1848条经验 获得超6个赞
SELECT column_Name1,column_name2,...... From tbl_name1,tbl_name2,tbl_name3 where tbl_name1.column_name = tbl_name2.column_name and tbl_name2.column_name = tbl_name3.column_name
添加回答
举报