简体   繁体   English

错误1052我试图使用内部联接联接表,但是我一直收到此消息

[英]error 1052 im trying to join tables using inner join however i keep getting this message

Im looking to join two tables together using inner join but i keep getting this error saying that 'column 'isbn' in field list is ambiguous'. 我希望使用内部联接将两个表联接在一起,但是我一直收到此错误消息,说“字段列表中的“ isbn列”是模棱两可的”。 Ive seen a few questions about this but none of them solved my problem. 我已经看到了一些与此有关的问题,但没有一个解决了我的问题。

SELECT isbn, title
FROM book 
INNER JOIN copy ON book.isbn = copy.isbn
    WHERE duration = '7';

I can see you have this column isbn in both copy and book table. 我可以看到您在copy表和book表中都有此isbn列。 So you have to choose which of this isbn columns is selected. 因此,您必须选择选择哪个isbn列。 so you should have 所以你应该有

SELECT book.isbn , title
FROM ....

Or 要么

SELECT copy.isbn , title
FROM ....

You are selecting a column that is present on both tables, so SQL can't distinguish which one to select. 您选择的是两个表中都存在的列,因此SQL无法区分要选择的列。 You have to specify it like this: 您必须像这样指定它:

SELECT book.isbn, title
FROM book 
INNER JOIN copy ON book.isbn = copy.isbn
    WHERE duration = '7';

or 要么

SELECT copy.isbn, title
FROM book 
INNER JOIN copy ON book.isbn = copy.isbn
    WHERE duration = '7';

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

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