View Single Post
Old 06-11-2024, 11:57 PM   #9
Trel
Connoisseur
Trel began at the beginning.
 
Posts: 66
Karma: 10
Join Date: Jan 2010
Device: Onyx Boox Poke 3
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

Last edited by Trel; 06-12-2024 at 12:02 AM.
Trel is offline   Reply With Quote