Union and Union All the difference between (a copy of the W3C School, copy again to remember!)

Union, UnionAll're both used to combine two or more query result set;

Union operator: select statement must have the same number of columns ( equal to the number of columns, the result consistent with different types of sets of data in the same column, the columns must be the same );

    A plurality of result sets of the union operation in line with each column name and subject to a name of the first result set.

   1. Union query lists all of China and the United States different from the name of the employee

Select name From Employee_china
Union
Select name From Employee_china;
  Query results will look like this:
zhang xiaoming 
Musi Zhan,
2. Union All query lists all of China and the United States different from the name of the employee
Select name From Employee_china
Union All
Select name From Employee_china;
  Query results will look like this:
zhang xiaoming 
Musi Zhan, 
xiaoming zhang

   Therefore: of Union All allows the result to set the combined duplicate rows; union: two or more than two appear exactly the same query results, taking only one .

 Note: The interviewer asks used it? Used! What's the difference? A: The second yellow background font!

Guess you like

Origin www.cnblogs.com/unknownCode/p/11872704.html