Closest Approximation to Relational Union - SQL
Actually, just as SQL has several varieties of JOIN, it also has several varieties of UNION, none of which is equivalent to the relational operator of that name. The closest approximation to relational union is illustrated in Example.
Example: SQL's closest approximation to relational union
SELECT StudentId
FROM IS_CALLED
WHERE Name = 'Devinder'
UNION DISTINCT CORRESPONDING
SELECT StudentId
FROM IS_ENROLLED_ON
WHERE CourseId = 'C1'
The key word DISTINCT is optional and implied by default (somewhat curiously so, considering that its opposite, ALL, is the default option in the SELECT clause). It specifies that no row is to appear more than once in the result. Thus, there is never a need to include DISTINCT in either of the SELECT clauses, and this would be the case even if the WHERE clause were omitted from the specification of the second operand in Example, allowing the same StudentId value to appear more than once in that operand.
The key word CORRESPONDING specifies that operand columns are to be paired by name, just as in relational union.