Realted to the UNION in sql

  • Hi all,

    Let say there are two select statement and we are using UNION to combine result from both select statement.

    Now the problem lies here:

    Let say that first select statement returns these rows

    ColumnA

    A

    A

    B

    C

    And second select statement return these rows

    ColumnB

    B

    C

    D

    D

    Now can any one please tell me what will be the result of the query where we are using union between those above select statements.

    Thanks

    Rajneesh

  • The result will be ABCD (ie four rows with an implicit distinct from the union, or you could use union all if you do not want the implied distinct.

    Not sure I understand why it is a problem though...

    Mike

  • ...and if you don't want to remove the duplicates, use UNION ALL rather than UNION.

  • The answer is ABCD

    as union remove all the duplicate values

    if You want to retain all values please use UNION ALL 🙂

  • kiranbgiet (1/7/2010)


    The answer is ABCD

    as union remove all the duplicate values

    if You want to retain all values please use UNION ALL 🙂

    Thank you for your valuable contribution 😛

  • To OP - not to sound harsh but pls lookup BOL and then ask your doubts. A Few doubts can be cleared by checking BOL.

    Hope my comments will be appreciated.

    "Keep Trying"

Viewing 6 posts - 1 through 5 (of 5 total)

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