The UNION clause combines the results from two or more SQL SELECT statements into a single result set containing rows from all the queries in the UNION operation.
Note: |
---|
When one of the columns is of Memo, General, or Blob type, performing unions of differing column types is not allowed. |
For the complete syntax, see SELECT - SQL Command.
The detailed syntax for the UNION clause is as follows:
[UNION [ALL] SELECTCommand] |
Parameters
- [UNION [ALL] SELECTCommand]
- Specifies another SELECT statement. By default, UNION eliminates duplicate rows from the combined result set.
Note: |
---|
The ALL keyword includes duplicate rows in the combined result set. |
Remarks
The following code shows a summary of the main clauses of the SELECT - SQL Command:
В | Copy Code |
---|---|
SELECT Select_List FROM Table_List ...[WITH (BUFFERING = lExpr)] [WHERE Conditions] [GROUP BY Column_List] [HAVING Conditions] [UNION Clause] [ORDER BY Column_List] [INTO Clause | TO Clause ] [Additional_Display_Options] |
For more information about a particular clause of the SQL SELECT command, see the following topics:
-
SELECT Clause
-
FROM Clause
-
SELECT - SQL Command - WITH Clause
-
SELECT - SQL Command - WHERE Clause
-
GROUP BY Clause
-
HAVING Clause
-
ORDER BY Clause
-
INTO or TO Clause
-
Additional Display Options
You can use the UNION clause to simulate an outer join. You can specify multiple UNION clauses; there is no limit on the number of UNION clauses per SELECT statement.
Visual FoxPro supports implicit data type conversion for data types that support it. For more information as well as rules and considerations concerning UNION clauses, see Considerations for SQL SELECT Statements.