显示给定表中的isbn、title、Author's(所有图书作者在一行中)的查询是什么?


What will be the query for displaying isbn, title, Author's (all the book authors in single line) from the given tables?

Book_title Table 
+---------------+-------------------+
| isbn          | title             |
+---------------+-------------------+
| 9780195153446 | classical         |
| 9780374157067 | flu: the stor     |
+---------------+-------------------+
Book_Authors table
+---------------+--------------------+
| Isbn_id       | Author             |
+---------------+--------------------+
| 9780195153446 | mark p. o. morford |
| 9780195153446 | robert j. lenardon |
| 9780374157067 | gina kolata        |
+---------------+--------------------+

要显示的查询是什么isbn,标题,作者(所有作者在一行)从给定的表。每本书可能有多个作者。

样本输出:

isbn                  title               author                author
9780195153446        classical      mark p. o. morford     robert j. lenardon
9780374157067        flu: the stor     gina kolata

我使用了这个查询

Select isbn, title, author from Book_title, Book_author Where Book_title.isbn = Book_author.isbn_id

但是如果同一本书有两个作者

您可以使用group_concat(并使用显式JOIN而不是旧的基于位置的关系)

      Select a.isbn, a.title, group_concat(b.author )
      from Book_title, 
      INNER JOIN Book_authoron a.isbn = b.isbn_id
      group by a.isbn, a.title