UNION
UNION
Combines the members of two or more result sets into a single set.
Syntax
set1 UNION set2
Parameters
set1 | The name of a result set that resulted from the execution of a set-producing command. Set1 and set2 must have the same component structure. |
set2 | The name of a result set that resulted from the execution of a set-producing command. Set1 and set2 must have the same component structure. |
Comments
When used within a FIND command, the set that results from the application of UNION contains all of the records from the specified sets, with duplicates being eliminated.
The sets must have the same component structure.
Example
find Employees (unrelated) WorkFor Managers keep Employees
find current (Employees -> Managers) -> MgrSet
% top level managers
find Employees WorkFor MgrSet keep Employees -> EmpSet
while
find Employees WorkFor EmpSet (Employees -> Managers) -> EmpMgrSet
if $setcount = 0
break
endif
find EmpMgrSet keep Managers -> NewMgrSet
find MgrSet union NewMgrSet -> MgrSet
endwhile
While the preceding program demonstrates the use of UNION, the program can be replaced with the single command shown below.
find Employees WorkFor Managers keep Managers -> MgrSet