创建视图时出现问题

kgsdhlau  于 2021-06-15  发布在  Mysql
关注(0)|答案(1)|浏览(327)

尝试在mysql中创建视图时收到此消息。我也尝试给每一列提供一个别名,但仍然收到一个错误。怎么了!?提前谢谢。
错误消息
错误1060:列名“id”重复
代码

CREATE VIEW contactnotes AS
SELECT contact.ID, log.ID, contact.Name, log.notes
FROM log 
JOIN contact 
ON log.ID = contact.ID

别名尝试

CREATE VIEW contactnotes AS
SELECT contact.ID as id1, log.ID as id2, contact.Name, log.notes
FROM log 
JOIN contact 
ON id1 = id2
fkaflof6

fkaflof61#

CREATE VIEW contactnotes AS
SELECT contact.ID as id1, log.ID as id2, contact.Name, log.notes
FROM log 
JOIN contact 
ON log.ID = contact.ID

或者

CREATE VIEW contactnotes AS
SELECT contact.ID as id1, log.ID as id2, contact.Name, log.notes
FROM log 
INNER JOIN contact USING (ID)

相关问题