James Gibson
James Gibson

Reputation: 21

getting unknown column when trying to move between multiple tables

This is my code

Select Lname,ISBN, Title
From Author, Books
Where Books.ISBN=BookAuthor.ISBN
AND Author.AuthorID=BookAuthor.AuthorID

It keeps telling me:

unknown column 'BookAuthor.ISBN' in 'where clause'

I've tried writing this backward and forward any help or explanation would be amazing thank you.

Upvotes: 2

Views: 25

Answers (1)

GMB
GMB

Reputation: 222632

Table BookAuthor does not appear in the FROM clause. Presumably, you are missing a join:

select a.lname, b.isbn, b.title
from author a
inner join bookauthor ba on ba.isbn     = a.isbn
inner join books      b  on b.author_id = ba.author_id

Note that this query uses standard, explicit joins, rather than old-school, implicit joins (with commas in the from clause): this very old syntax is much harder to follow and should not be used in new code.

Upvotes: 1

Related Questions