2013-01-16 125 views
0

任何人都可以幫助我從我的家庭表中選擇一個家庭的查詢,也可以從另一個表中得到一個列表值列表到一個列中。該查詢來自我發佈在這裏的另一個問題的幫助,但是我現在試圖根據需要添加到查詢中。當我嘗試添加一個列的形式另一個表Oracle拋出一個無效的標識符錯誤下面是我的查詢;SQL無效標識符

SELECT homes.title, homes.description, homes.living_room_count, homes.bedroom_count, homes.bathroom_count, homes.price, homes.sqft, 
listagg(features.feature_name, ',') WITHIN GROUP (ORDER BY features.feature_name) features, home_type.type_name, home_photo.photo, home_photo.description 
FROM homes, home_type, home_photo 
INNER JOIN home_feature 
    ON homes.home_id = home_feature.home_id 
INNER JOIN features 
    ON home_feature.feature_id = features.feature_id 
INNER JOIN home_photo 
    ON home_photo.home_id = homes.home_id 
WHERE home_type.type_code = homes.type_code AND homes.homes_id = home_photo.home_id 
GROUP BY homes.title, homes.description, homes.living_room_count, homes.bedroom_count, homes.bathroom_count, homes.price, homes.sqft, home_type.type_name; 

上面的查詢拋出這個,但列是確實是正確的:

ORA-00904: "HOMES"."HOME_ID": invalid identifier 
00904. 00000 - "%s: invalid identifier" 
*Cause:  
*Action: 
Error at Line: 5 Column: 4 

從我的其他問題,結果在查詢工作移除列到原來的查詢?下面是添加了其他列的不同表之前的工作查詢:

SELECT homes.title, homes.description, homes.living_room_count, homes.bedroom_count, homes.bathroom_count, homes.price, homes.sqft, 
listagg(features.feature_name, ',') WITHIN GROUP (ORDER BY features.feature_name) features 
FROM homes 
INNER JOIN home_feature 
    ON homes.home_id = home_feature.home_id 
INNER JOIN features 
    ON home_feature.feature_id = features.feature_id 
GROUP BY homes.title, homes.description, homes.living_room_count, homes.bedroom_count, homes.bathroom_count, homes.price, homes.sqft; 

謝謝你,如果有人可以提供幫助。

+0

您不能將Oracle樣式連接與ansi 92樣式連接混合使用。 –

回答

1
SELECT homes.title, homes.description, homes.living_room_count, homes.bedroom_count, homes.bathroom_count, homes.price, homes.sqft, 
listagg(features.feature_name, ',') WITHIN GROUP (ORDER BY features.feature_name) features, home_type.type_name, home_photo.photo, home_photo.description 
FROM homes 
INNER JOIN home_feature 
    ON homes.home_id = home_feature.home_id 
INNER JOIN home_type 
    ON home_type.type_code = homes.type_code 
INNER JOIN home_photo 
    ON homes.homes_id = home_photo.home_id 
INNER JOIN features 
    ON home_feature.feature_id = features.feature_id 
INNER JOIN home_photo 
    ON home_photo.home_id = homes.home_id 
GROUP BY homes.title, homes.description, homes.living_room_count, homes.bedroom_count, homes.bathroom_count, homes.price, homes.sqft, home_type.type_name; 

會工作。即不要混淆ANSI + oracle連接語法。