1

如您所知,calibre有一个名为metadata.dbSQLite 并由 SQLite 制成的数据库,我想从所有具有此列的书籍中查询:

bookId  Title   Date    Size    Rating  Tags    Publisher   PublishedDate   Author  Cover           
------  -----   ----    ----    ------  ----    ---------   -------------   ------  -----

但是,该数据库包含此表:

Books Table
-----------
Name
id
title
sort
timestamp
pubdate
series_index
author_sort
isbn
lccn
path
flags
uuid
has_cover
last_modified


Authors Table
-------------
Name
id
name
sort
link


Publishers Table
----------------
Name
id
name
sort

他们之间没有关系,我怎样才能得到我的查询?

4

1 回答 1

6
SELECT id, title,
               (SELECT name FROM books_authors_link AS bal JOIN authors ON(author = authors.id) WHERE book = books.id) authors,
               (SELECT name FROM publishers WHERE publishers.id IN (SELECT publisher from books_publishers_link WHERE book=books.id)) publisher,
               (SELECT rating FROM ratings WHERE ratings.id IN (SELECT rating from books_ratings_link WHERE book=books.id)) rating,
               (SELECT MAX(uncompressed_size) FROM data WHERE book=books.id) size,
               (SELECT name FROM tags WHERE tags.id IN (SELECT tag from books_tags_link WHERE book=books.id)) tags,
               (SELECT format FROM data WHERE data.book=books.id) formats,
               isbn,
               path,
               pubdate
        FROM books
于 2013-02-15T17:52:20.250 回答