Wednesday, February 27, 2013

UNION ALL SET Operator

The UNION ALL operator merges the result sets of two component queries. This operation returns rows retrieved by either of the component queries. The following example illustrates the UNION ALL operation:


The Syntax of UNION ALL is

<Component Query>
UNION ALL
<Component Query>

For Example:

SELECT CUST_NBR, NAME FROM CUSTOMER WHERE REGION_ID = 5
UNION ALL
SELECT C.CUST_NBR, C.NAME FROM CUSTOMER C WHERE C.CUST_NBR IN (SELECT O.CUST_NBR  FROM CUST_ORDER O, EMPLOYEE E
WHERE O.SALES_EMP_ID = E.EMP_ID  AND E.LNAME = 'MARTIN');

No comments:

Post a Comment