我有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查询。
提前谢谢
答案 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