Nonstop Database, HiRDB Version 9 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.
The following figure shows, as an example of a data search using a subquery, the procedure for searching the stock table for the product codes of products whose price equals or exceeds 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.
The following figure shows, as an example of a subquery using a qualified predicate, the procedure for retrieving from the stock table the product codes and names of all products whose quantity in stock is greater than the quantity in stock for any 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.
The following figure shows, as an example of a subquery using the EXISTS predicate, the procedure for retrieving from the stock and order tables the names of all products for which no orders have been received.
Figure 2-32 Example of a subquery using the EXISTS predicate
All Rights Reserved. Copyright (C) 2011, Hitachi, Ltd.