编译语句时出错:FAILED:SemanticException [错误10036]:重复列名:p_id

时间:2018-03-09 15:00:54

标签: mysql view hive hiveql

何时

SELECT * from hospital_basic 
LEFT JOIN hospital_clinical on hospital_basic.p_id=hospital_clinical.p_id;

它工作正常,但在创建视图时出现错误

CREATE VIEW hospital_view AS
SELECT * from hospital_basic LEFT JOIN 
hospital_clinical on hospital_basic.p_id=hospital_clinical.p_id;

1 个答案:

答案 0 :(得分:2)

您需要为您选择的列添加别名,不能执行select *,因为列p_id将与表定义重复

CREATE VIEW hospital_view AS 
SELECT 
hospital_basic.p_id as hospital_basic_p_id,
hospital_clinical.p_id as hospital_clinical_p_id,
other columns   ...
from hospital_basic LEFT JOIN hospital_clinical on hospital_basic.p_id=hospital_clinical.p_id;