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

问题描述 投票:0回答:2

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;
mysql view hive hiveql
2个回答
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;

0
投票

请帮我解决这个问题

hive> 创建表示例 > AS > SELECT a.stock_symbol, b.stock_symbol, Month(a.stock_date), (AVG(a.stock_price_high*b.stock_price_high)-(AVG(a.stock_price_high)*AVG(b.stock_price_high))) FROM nyse a JOIN nyse b ON (a.stock_date=b.stock_date) WHERE a.stock_symbol

失败:SemanticException [错误 10036]:重复的列名称:stock_symbol

© www.soinside.com 2019 - 2024. All rights reserved.