2012-06-13 30 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