SELECT
    flashcard.id,
    flashcard.question,
    flashcard.answer,
    review.scheduled,
    review.reviewed,
    review.difficulty,
    review.stability,
    review.rating
FROM flashcard
LEFT JOIN review
    ON flashcard.id = review.flashcard_id
WHERE
    flashcard.deck_id = (
        SELECT id FROM deck WHERE name = ?1
    )
    AND
    flashcard.id IN RARRAY(?2)
ORDER BY
    flashcard.id ASC,
    review.reviewed ASC;
