When will union and union all behave the same?

Total Post:2

Points:10
 652  View(s)
Ratings:
Rate this:
  1. Post:2

    Points:10
    When will union and union all behave the same?

    Union will return record only once even if it occurs several times. Union all will give a record as many times as it occurs. So union and union all will behave the same when each record is distinct in all the participating tables.

    eg

    select name, id from Emp1 union select name, id from Emp2
    

    select name, id from Emp1 union all select name, id from Emp2

Answer