1

尝试在 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
4

1 回答 1

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)
于 2013-03-15T00:23:28.183 回答