何时
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;
答案 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;