编译语句时出错:FAILED:SemanticException [错误 10036]:列名重复:p_id
Posted
技术标签:
【中文标题】编译语句时出错:FAILED:SemanticException [错误 10036]:列名重复:p_id【英文标题】:Error while compiling statement: FAILED: SemanticException [Error 10036]: Duplicate column name: p_id 【发布时间】:2018-03-09 15:00:54 【问题描述】:当
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】:您需要为您选择的列添加一个别名,您不能这样做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;
【讨论】:
那么,如果两者都有20列,我必须全部写出来吗? 您可以使用正则表达式排除除一个以外的所有内容。 ***.com/questions/31666905/…以上是关于编译语句时出错:FAILED:SemanticException [错误 10036]:列名重复:p_id的主要内容,如果未能解决你的问题,请参考以下文章
编译语句时出错:FAILED: SemanticException [Error 10002] - MAKE SELECT WITH MAX ON HIVE
Android Studio3.1.2编译时Java Compiler出错:Warning: Failed to parse host proxy3.bj...
cordova发布编译出错,提示:cordova-build error : Execution failed for task ':mergeReleaseResources'.或(
cordova发布编译出错,提示:cordova-build error : Execution failed for task ':mergeReleaseResources'.或(
maven 编译出错 Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean
maven 编译出错 Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean