Partager via


SELECT - SQL Command - UNION Clause

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:

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:

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

Reference

CREATE QUERY Command
CREATE TABLE - SQL Command
MODIFY QUERY Command

Other Resources

Working with Queries
Working with Views (Visual FoxPro)
Query and View Designers