Question

    What is the primary purpose of the UNION ALL operator in SQL?

    A To combine the results of two or more queries, excluding duplicate rows from the final result. Correct Answer Incorrect Answer
    B To combine the results of two or more queries, including all rows, even if they are duplicates. Correct Answer Incorrect Answer
    C To update records in a table based on the results of multiple queries. Correct Answer Incorrect Answer
    D To create a new table that contains the combined schema of two or more existing tables. Correct Answer Incorrect Answer
    E To delete all records from multiple tables in a single operation. Correct Answer Incorrect Answer

    Solution

    The UNION ALL operator in SQL is used to combine the results of two or more queries into a single result set. Unlike the UNION operator, which removes duplicate rows from the final result set, UNION ALL includes all rows, regardless of duplication. This makes UNION ALL useful when you want to retain all the data from the combined queries, including duplicates.

    Practice Next