2013-01-16 122 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连接语法。