简体   繁体   English

我的 Sql(MySQL 说:#1052 - 字段列表中的列 'hswhouse.whname' 不明确

[英]My Sql(MySQL said: #1052 - Column 'hswhouse.whname' in field list is ambiguous

create view House as 
SELECT hswhouse.whname,hsitems.description,hsitems.numInStock
from hswhouse
inner join hsitems
inner join hswhouse on hswhouse.whnum = hsitems.whouseNum
where hswhouse.whname = "San Diego"

and MySQL said:和 MySQL 说:

#1052 - Column 'hswhouse.whname' in field list is ambiguous #1052 - 字段列表中的列“hswhouse.whname”不明确

You have table hswhouse twice in the query, without aliases, so it is indeed ambiguous to which of them table name hswhouse refers.您在查询中有两次表hswhouse ,没有别名,因此表名hswhouse所指的表名确实不明确。

Looking at your query, one of the join s is missing a on clause (which is a syntax error in most databases apart from MySQL), and it really seems like you need table hswhouse just once.查看您的查询,其中一个join缺少on子句(这是除 MySQL 之外的大多数数据库中的语法错误),并且您似乎只需要一次表hswhouse Most likely, you want:最有可能的是,您想要:

create view House as 
SELECT h.whname, i.description, i.numInStock
from hswhouse h
inner join hsitems i on h.whnum = i.whouseNum
where h.whname = 'San Diego'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM