-2

数据库就像:

table book: book_id, title

table wrote: book_id, author_id, author_order

table author: author_id, author_name

每本书都是由几个人写的,并且有 author_order。

我需要使用 c 程序输出,例如:

book_id

authors: author1, author2, ... , authork

title

现在我使用游标来获取 book_id 和 title,但是如何获取所有写书的作者呢?

4

1 回答 1

1

您的数据模型非常简单,我认为您需要的只是从作者到写书的连接。

SELECT author_id, author_name, bookid, title
  FROM author
  JOIN wrote 
    ON (author.authorid = wrote.authorid)
  JOIN book
    ON (wrote.bookid = book.bookid)
于 2012-06-21T20:36:50.520 回答