MySQL Displaying columns from multiple tables

I have two tables: book & publisher

book columns are: book_code, title, publisher_code

publisher columns are: publisher_code, publisher_name

I am trying to display each book title with it’s book_code, publisher_code, & publisher_name

so far this is what I have:

select book_code, title, a.publisher_code
from book a
inner join publisher p
on a.publisher_code = p.publisher_code;

I’m unsure how to also display the publisher_name

Answer

In mysql here is how I would have wrote it:

SELECT
  b.book_code,
  b.title,
  b.publisher_code,
  p.publisher_name
FROM
  book AS b
    JOIN publisher AS p USING (publisher_code);

Leave a Reply

Your email address will not be published. Required fields are marked *