MERGE

<< Click to Display Table of Contents >>

Navigation:  Apollo SQL > DDL & DML Statements >

MERGE

 

The MERGE statement, also known as UNION in other SQL dialects, is a command that will append one result set, to another result set. The number of columns in the first result set to append must correspond with the number of columns in the second result set. Also, the type of fields must correspond: strings with strings float with floats, etc.

image\tip.gif Use the Open method (or set the Active property to True) to execute a MERGE statement.

Syntax:

MERGE sql_statement WITH another_sql_statement

Example:

MERGE SELECT * FROM Orders WHERE CustNo > 5000 ORDER BY SaleDate

WITH SELECT * FROM Orders WHERE CustNo BETWEEN 1000 AND 3000;

In general, you can mix in any SQL statement. All of the usual syntax is supported including subqueries, JOINing, GROUPing, ORDERing, and so on.

image\tip.gif MERGE can be joined with results coming from different tables and not just from the same table, as in the example above.