2012-06-13 33 views
3

的Roomattributes说明我有3个表是我的SQL数据库:我怎样才能得到属于客房SQL

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

我怎样才能获得Roomattributes,属于客房。我需要一个SQL查询。

预先感谢您

回答

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 
+0

非常感谢!您的查询工作如同魅力! :) – Paks

+0

不客气...! – Nalaka526