JavaScript Editor js editor     Web development 

Main Page

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.

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:




Specifies another SELECT statement. By default, UNION eliminates duplicate rows from the combined result set.
The ALL keyword includes duplicate rows in the combined result set.


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 ]

For more information about a particular clause of the SQL SELECT command, see the following topics:

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.

See Also

JavaScript Editor js editor     Web development