Fragen zu komplexeren INNER|LEFT JOINs

In etwa so gehts ev.
Code:
SELECT * 
FROM 
    movie_list AS ml
    LEFT JOIN 
        source_movies AS sm
        ON ml=sm
    LEFT JOIN 
        (SELECT
            mp1.*
        FROM 
            movie_pictures AS mp1
        WHERE
            mp.id IN ( SELECT id
                    FROM  movie_pictures mp2
                    WHERE mp2.movie_id = mp1.movie_id
                    ORDER BY mySortCriteria
                    LIMIT 1)) AS mp
        ON ml.id = mp.movie_id
    LEFT JOIN 
        source_pictures AS sp
        ON mppicture_id = sp.id
WHERE movie_list.customer_id=1

Der folgende Teil nimmt den ersten nach deinem Sortierungsbefehl:
Code:
SELECT
    mp1.*
FROM 
    movie_pictures AS mp1
WHERE
    mp.id IN ( SELECT id
            FROM  movie_pictures mp2
            WHERE mp2.movie_id = mp1.movie_id
            ORDER BY mySortCriteria
            LIMIT 1)
 
Zurück