UNION Statement

  • Is it possible to have a SQL Statement which selects data from each of two different tables and performs a UNION with the results?

    E.g. Select c1, c2, c3 from TableA

    UNION

    Select c1, c4, c5 from TableB?

  • Yes. According to Books-On-Line (BOL)

    <quote>

    Two basic rules for combining the result sets of two queries with UNION are:

    1) The number and the order of the columns must be identical in all queries.

    2) The data types must be compatible.

    </quote>

    HTH

    Billy

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply