Oracle
 sql >> Base de Dados >  >> RDS >> Oracle

SELECT usando a cláusula UNION


Você deve usar INTERSECT e MINUS (para Oracle):
-- At least at Boston or at Dallas 
(SELECT DNAME 
   FROM DEPARTMENT 
  WHERE CITY = 'DALLAS'

UNION

 SELECT DNAME 
   FROM DEPARTMENT 
  WHERE CITY = 'BOSTON')

MINUS

-- At Boston and at Dallas
(SELECT DNAME 
   FROM DEPARTMENT 
  WHERE CITY = 'DALLAS'

INTERSECT

 SELECT DNAME 
   FROM DEPARTMENT 
  WHERE CITY = 'BOSTON')

Desde UNION adiciona subconsultas enquanto EXCEPT /MINUS subtrai eles