📜  UNION ALL LEFT JOIN - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:34.709000             🧑  作者: Mango

代码示例1
SELECT
    comments.*, users.company, users.contact_person, users.email
    FROM
        comments
    LEFT JOIN users ON users.user_id = comments.user_id
    WHERE
        comment_id = %s
UNION ALL
SELECT activity.*, users.company, users.contact_person, users.email
    FROM
        activity
    LEFT JOIN users ON users.user_id = activity.user_id
    WHERE
        comment_id = %s
ORDER BY
    timestamp ASC