Reputation: 11
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';
Upvotes: 0
Views: 47
Reputation: 818
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';
Upvotes: 1
Reputation: 1479
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 ....
Upvotes: 3