如何获取属于Rooms SQL的Roomattributes描述

时间:2012-06-13 07:38:05

标签: sql sql-server-2008

我有3个表是我的SQL数据库:

First Table: Room: ID <pk>, Roomname
Second Table: RoomRelationsship: ID<pk>, Room_ID <fk>, Roomattributes_ID<fk>
Third Table: Roomattributes: ID<pk>, Attributename

我如何获得属于Rooms的Roomattributes。我需要一个SQL查询。

提前谢谢

1 个答案:

答案 0 :(得分:3)

SELECT Room.ID, Room.Roomname, Roomattributes.Attributename 
FROM Room 
INNER JOIN RoomRelationsship ON RoomRelationsship.Room_ID = Room.ID
INNER JOIN Roomattributes ON RoomRelationsship.Roomattributes_ID = Roomattributes.ID