MySql - 无法创建视图 [英] MySql - Trouble Creating View

查看:84
本文介绍了MySql - 无法创建视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在 MySql 中创建视图时收到此消息.我也试过给每列一个别名,但仍然收到错误.什么哈!?提前致谢.

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.

错误信息

错误 1060:列名ID"重复

ERROR 1060: Duplicate column name '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

推荐答案

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)

这篇关于MySql - 无法创建视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆