-1

如何链接并获取三个表的变量,我想获取每个房间的链接设施,但目前我的记录似乎没有返回任何内容。

我也想为设施返回一个新的列标题:http ://sqlfiddle.com/#!2/8d6ca/25

小提琴可以在这里找到

SELECT *
FROM ts_room rm
WHERE 
NOT EXISTS (
SELECT 1
FROM ts_roompref rp
JOIN ts_request rq ON rp.request_id = rq.id AND day_id = 1 AND period_id = 1
WHERE rm.id = rp.room_id)
AND NOT EXISTS (
SELECT 1
FROM ts_roompref rp
JOIN ts_allocation a ON rp.request_id = a.request_id AND a.status = "Allocated" 
WHERE rm.id = rp.room_id)
AND EXISTS (
SELECT 1
FROM ts_roomfacilities f
JOIN ts_room b ON f.room_id = b.id 
WHERE rm.id = f.room_id AND 
f.facilities_id=2);
AND EXISTS (
SELECT 1
FROM ts_facilities f1
JOIN ts_roomfacilities c ON f2.id = c.id 
WHERE rm.id = f.room_id);
4

1 回答 1

0

有个 ; 在您应该删除的查询中间

于 2013-02-18T00:31:52.630 回答