How to Use the UNION Clause in a FoxPro SELECT StatementLast reviewed: April 30, 1996Article ID: Q119901 |
The information in this article applies to:
SUMMARYThe UNION clause is used to join the results of multiple queries. However, the UNION clause is not supported by the Relational Query By Example (RQBE) tool because the RQBE tool does not support multiple or nested queries. Therefore, to perform queries of this type, the SELECT statement must be coded by hand.
MORE INFORMATIONThe UNION clause is a very important clause in the SELECT statement because it allows you to append the results of a query to the results of another query. The syntax is:
UNION [ALL] <SELECT statement>The ALL clause prevents UNION from eliminating duplicate rows from the combined results of the tables. NOTE: There is no limit to the number of UNION clauses that can be used, except that the whole SELECT statement is limited to 2048 characters. There are three rules you need to follow when using a UNION clause. They are as follows:
Numeric: 0 Character: " " Date: {} Logical: .F. Memo: Not available. Use workaround described below.To create a placeholder for a memo field:
SELECT *,placehold FROM customer, holdmemo INTO CURSOR testThe resulting query will have a blank memo field as the last field for each record. This behavior occurs because there is not a join condition for the databases, which creates a Cartesian product. In other words, each record in the first table is matched with each record in the second table. For another example of the UNION clause, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q89181 TITLE : Outer Join Syntax Example for SELECT-SQL Statement REFERENCESFoxPro "Language Reference," see "SELECT-SQL" "Using FoxPro 2.5 for Windows," Que Publishing, pages 266-267
|
KBCategory: kbprg
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |