简体   繁体   中英

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'. 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. So you have to choose which of this isbn columns is selected. 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. 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';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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