You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Combines the results of two queries into a single result set. You control whether the result set includes duplicate rows:
28
+
Concatenates the results of two queries into a single result set. You control whether the result set includes duplicate rows:
29
29
30
30
-**UNION ALL** - Includes duplicates.
31
31
-**UNION** - Excludes duplicates.
32
32
33
-
A UNION operation is different from a JOIN:
33
+
A **UNION** operation is different from a **[JOIN](../queries/from-transact-sql.md)**:
34
34
35
-
- A UNION combines result sets from two queries. But a UNION does not create individual rows from columns gathered from two tables.
36
-
- A JOIN compares columns from two tables, to create rows composed of columns from two tables.
35
+
- A **UNION** concatenates result sets from two queries. But a **UNION** does not create individual rows from columns gathered from two tables.
36
+
- A **JOIN** compares columns from two tables, to create result rows composed of columns from two tables.
37
37
38
-
The following are basic rules for combining the result sets of two queries by using UNION:
38
+
The following are basic rules for combining the result sets of two queries by using **UNION**:
39
39
40
40
- The number and the order of the columns must be the same in all queries.
41
41
42
42
- The data types must be compatible.
43
43
44
-
[Transact-SQL Syntax Conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
44
+
[Transact-SQL Syntax Conventions](transact-sql-syntax-conventions-transact-sql.md)
0 commit comments