MySQL显示多个表中的列

时间:2014-12-05 16:23:14

标签: mysql sql database

我有两张桌子:book&出版商

书籍栏目是:book_code,title,publisher_code

发布商列是:publisher_code,publisher_name

我正在尝试使用book_code,publisher_code和&amp ;; PUBLISHER_NAME

到目前为止,这就是我所拥有的:

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

我不确定如何显示publisher_name

1 个答案:

答案 0 :(得分:0)

在mysql中我就是这样写的:

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