我正在尝试使用SQLite.swift运行相当复杂的SQL JOIN,并将结果放入数组中。将select的结果分配给数组没有问题,但我不确定这是否是执行此类连接的正确或最佳方法。
var results = [Row]()
results = Array(try db.execute("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 format FROM data WHERE data.book=books.id) formats, path FROM books"))
results.count最终为0。