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;
大家好,所以我试图使用内部联接创建视图。我得到错误代码,如标题。任何人都知道这是“模棱两可”的意思吗?
谢谢。
答案 0 :(得分:2)
在这一行:
FROM bookings, customers inner join bookings
您正在将bookings
加入customers
(使用隐式加入运算符,
),然后再加入bookings
。因此,您的bookings
中有两个JOIN
表,MySQL无法确定从哪个表中获取该列。
您可能只打算添加一次bookings
,请尝试将查询更改为
FROM customers inner join bookings
或者如果您要做需要两次加入预订表,则可以在表名中添加一个别名,以使它们彼此区分,即
FROM bookings AS bookings_1, customers inner join bookings AS bookings_2