I'm trying to do this to be able to export things like CSV and similar.
My final query which looks to be working is
Code:
SELECT
series_id
,book_id
,MAX(series_index) AS series_index
,series
,title
,read_status
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
,cc2.value AS read_status
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
LEFT join books_custom_column_2_link AS bcc2
ON b.id = bcc2.book
LEFT join custom_column_2 AS cc2
ON bcc2.value = cc2.id
)
GROUP BY
series_id
ORDER BY
series ASC;
I can add a WHERE clause to the outer query to filter on the read status
EDIT: this is all precursor for me searching out and finding if I've completed a completed series and adding custom metadata to that effect, but also something I frequently try to look up