getting unknown column when trying to move between multiple tables

Viewed 24

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.

1 Answers

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.

Related