0
votes

i have the following relational database tables

enter image description here

to get the author name of a certain book i made the following query

SELECT authors.name

FROM authors

INNER JOIN book_author ON authors.id=book_author.author_id

INNER JOIN books

ON books.id=book_author.book_id WHERE books.id=1;

but it is giving me the error in the title .How i can fix that ?

1

1 Answers

1
votes

Name is not a field in the table "authors". Select authors.author_name and it will run.

SELECT authors.author_name

FROM authors

INNER JOIN book_author ON authors.id=book_author.author_id
WHERE book_author.book_id=1;