View Single Post
Old 06-11-2024, 07:23 PM   #7
Trel
Connoisseur
Trel began at the beginning.
 
Posts: 64
Karma: 10
Join Date: Jan 2010
Device: Onyx Boox Poke 3
I know it's considered poor form to hit the database directly, but I managed to get this to so far grab the latest book in all series, I'm going to incorporate my custom Read/Unread column soon. Is there any real harm/risk in opening the DB in read only mode and running selects?

Code:
SELECT
    series_id
    ,book_id
    ,MAX(series_index) AS series_index
    ,series
    ,title
FROM
(
    SELECT
        s.sort AS series
        ,b.id AS book_id
        ,b.title AS title
        ,s.id AS series_id
        ,b.series_index AS series_index
    FROM
        books_series_link AS bs
    LEFT JOIN books AS b
        ON bs.book = b.id
    LEFT JOIN series AS s
        ON bs.series = s.id
)
GROUP BY
    series_id
ORDER BY
    series ASC;
Trel is offline   Reply With Quote