MySql - 无法创建视图

时间:2013-03-15 00:20:09

标签: mysql views

尝试在MySql中创建视图时收到此消息。我尝试过为每个列提供别名,但仍然收到错误。 Wha Happon!?提前谢谢。

错误消息

  

错误1060:重复列名'ID'

代码

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

Alias Attempt

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

1 个答案:

答案 0 :(得分:4)

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)