Explain mechanism of nested queries?
SQL gives a mechanism for nesting subqueries. A subquery is a select from where expression that is nested within one more query. A common use of sub queries is to perform tests for set membership, make set comparisons, and verify set cardinality.
a) Set membership
(select customer-name
from depositor)
b) Set comparison
select distinct T.branch-name
from branch as T,branch as S
where T.assets > S.assets and S.branch-city='Brooklyn'
a) Test for Empty Relations
Select customer-name
from borrower
where exits (select *
from depositor
where depositor.customername=borrower.customer-name)
a) Test for the Absence of Duplicate Tuples