WITH
    params AS (
        SELECT
            2199023256684 AS id,
            CAST ('2011-05-08' AS TIMESTAMP(3)) AS dte
    ),
    messages AS (
            SELECT persons.id, persons.firstName, persons.lastName, posts.id AS message_id, COALESCE(posts.content, posts.imageFile) AS content, posts.creationDate
            FROM posts, persons
            WHERE posts.creator = 2199023256684 AND persons.id = posts.creator AND posts.creationDate <= CAST('2011-05-08' AS TIMESTAMP(3))
        UNION ALL
            SELECT persons.id, persons.firstName, persons.lastName, comments.id AS message_id, comments.content, comments.creationDate
            FROM comments, persons
            WHERE comments.creator = 2199023256684 AND persons.id = comments.creator AND comments.creationDate <= CAST('2011-05-08' AS TIMESTAMP(3))
    )
SELECT  * FROM messages
ORDER BY creationDate DESC, message_id
;
    