Database Reference
In-Depth Information
Figure 6.34
Use nested queries.
Figure 6.35
Use EXISTS with subquery.
With operators such as EXISTS and NOT EXISTS, you can apply subqueries to generate the
following sets of data selected from two original tables:
Intersection : Contains rows that exist in both original tables
Diference : Contains rows only in the irst original table but not in the second original table
(not including the rows in both tables)
Union : Contains all rows that exist in both the original tables
Product : Contains all the matches that associate every row of the irst table with every row
of the second table
For example, the intersection of CLASS and DAYS is the set of days on which classes are
scheduled. Figure 6.36 shows the intersection generated with the EXISTS operator.
Similar to the above example, the diference of DAYS and CLASS should contain those days
that have not been assigned. Figure 6.37 displays the diference generated with the NOT EXISTS
operator.
As shown in Figure 6.37, Friday, Saturday, and Sunday are the elements in DAYS but not the
elements in CLASS. he set of elements is the diference.
Search WWH ::




Custom Search