[英]#1052 - Column 'bookings.chauffeur_req' in field list is ambiguous
CREATE VIEW chauffeursreuqired AS
SELECT customers.customer_id, customers.fname, customers.lname, bookings.chauffeur_req, bookings.booking_id
FROM bookings, customers inner join bookings
ON customers.customer_id = bookings.customer_id;
Hey all, so Im trying to create a view using an inner join. 大家好,所以我正在尝试使用内部联接创建视图。 im getting the error code as in the title.
我得到错误代码,如标题。 Anyone has an idea what it means that it is 'ambiguous'?
任何人都知道这是“模棱两可”的意思吗?
Thanks. 谢谢。
In this line: 在这一行:
FROM bookings, customers inner join bookings
You are joining bookings
to customers
(using the implicit join operator ,
) and then to bookings
again. 要加入
bookings
到customers
(使用隐式连接运营商,
),然后bookings
一次。 So you have two bookings
table in your JOIN
and MySQL can't determine which one to fetch that column from. 因此,您的
JOIN
有两个bookings
表,而MySQL无法确定从哪个表中获取该列。
You probably only meant to include bookings
once, try changing your query to 您可能只打算包含一次
bookings
,请尝试将查询更改为
FROM customers inner join bookings
Or if you do need to join the bookings table twice, you can add an alias to the table names to allow them to be distinguished from each other ie 或者,如果您确实需要两次加入预订表,则可以在表名中添加一个别名,以使它们彼此区分,即
FROM bookings AS bookings_1, customers inner join bookings AS bookings_2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.