View Single Post
Old 02-04-2021, 11:24 AM   #10
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,356
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
BTW, the reason your SQL doesn't work is that some of the subqueries return multiple rows. You only see the first one. To see all of them you need to use group_concat(), like this:
Code:
SELECT
    id,
    author_sort,
    title,
    (SELECT name FROM publishers WHERE publishers.id IN (SELECT publisher from books_publishers_link WHERE book=books.id)) publisher,
    (SELECT group_concat(format) FROM data WHERE data.book=books.id) formats,
    path,
    (SELECT group_concat(name) FROM tags WHERE tags.id IN (SELECT tag from books_tags_link WHERE book=books.id)) tags
FROM books
chaley is offline   Reply With Quote