Scalable Database Server, HiRDB Version 8 UAP Development Guide
A query can be represented structurally by specifying values of the query results in a search condition. A subquery allows an easy access to complex queries in a database.
Figure 2-30 shows an example of a data search using a subquery. This example retrieves from a stock table the product codes of products whose prices equal or exceed the average price.
Figure 2-30 Data search example using a subquery
A quantified predicate can be used to determine whether or not the results of a subquery satisfy a specified set of comparison conditions and to further narrow the retrieval results. Figure 2-31 shows an example of a subquery using a quantified predicate. The example retrieves from the stock table the product codes and names of products with a greater stock quantity than any quantity of blouse (regardless of the product code).
Figure 2-31 Data search example using a subquery and a quantified predicate
The EXISTS predicate is used to test whether or not the results of a subquery are an empty set.
Figure 2-32 shows an example of a subquery using the EXISTS predicate. The example retrieves from the stock table and the order table the names of products for which no orders have been placed.
Figure 2-32 Example of a subquery using the EXISTS predicate
All Rights Reserved. Copyright (C) 2007, Hitachi, Ltd.