UNION

UNION merges the rows of two or more tables into one report. To make sense, these rows should relate to one another, have the same width, and have the same data type. Using UNION, you can merge values from two or more tables into the same columns, but different rows, of the same report. You can use UNION more than once in a query.

Examples in this section that use UNION ALL require enhanced UNION support. See Appendix C. QMF Functions that Require Specific Support.

The following example selects the name and employee columns from Q.STAFF and the name and applicant columns from Q.APPLICANT.

SELECT NAME, 'EMPLOYEE '
FROM Q.STAFF
WHERE YEARS < 3
 UNION
SELECT NAME, 'APPLICANT'
FROM Q.APPLICANT
WHERE EDLEVEL > 14
[ Previous Page | Next Page | Contents | Index ]