请帮我看看我在这里做错了什么:
从命令行中的第1行开始出错 -
CREATE VIEW VW_ROUTE AS
SELECT ROUTE_NAME
, FARE
, DESTINATION
, ROUTE_ID
, STOP_NAME
, TERMINUS
, NUMBER_OF_STOPS
FROM STOPS S
LEFT JOIN ROUTE R
ON S.ROUTE_ID = R.ROUTE_ID
WHERE NUMBER_OF_STOPS > ('1')
Error at Command Line : 5 Column : 10 Error report - SQL Error: ORA-00918: column ambiguously defined 00918. 00000 - "column ambiguously defined" *Cause: *Action:
答案 0 :(得分:5)
两个表中都有相同的列名。添加别名。
CREATE VIEW VW_ROUTE AS
SELECT ROUTE_NAME
, FARE
, DESTINATION
, S.ROUTE_ID -- ROUTE_ID exists in table STOPS/ROUTE
, STOP_NAME
, TERMINUS
, NUMBER_OF_STOPS
FROM STOPS S
LEFT JOIN ROUTE R
ON S.ROUTE_ID = R.ROUTE_ID
WHERE NUMBER_OF_STOPS > ('1');
好的做法是在所有出现时使用别名以避免含糊不清。