MySql - Trouble Creating View

2019-03-01 14:18发布

Receiving this message when trying to create a view in MySql. I've tried giving an alias to each column as well and still receive an error. Wha Happon!? Thanks in advance.

Error Message

ERROR 1060: Duplicate column name 'ID'

Code

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

标签: mysql views
1条回答
你好瞎i
2楼-- · 2019-03-01 14:57
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

or

CREATE VIEW contactnotes AS
SELECT contact.ID as id1, log.ID as id2, contact.Name, log.notes
FROM log 
INNER JOIN contact USING (ID)
查看更多
登录 后发表回答