subquery
@developeramit (3)
India
     
    
    2 responses
         @nill_07 (1104)
 • Bangladesh
                    9 Apr 07
                    A subquery is a SELECT-FROM-WHERE expression that is nested within another query.
A common use of subquery is to perform tests for Set Membership,Set Comparisons,and Set Cardinality.
Example:
!! Find all customer who have both an account and a loan at the bank.
SELECT DISTINCT customer_name
FROM borrower
WHERE customer_name IN (SELECT customer_name FROM depositor)
Additonal: Here borrower schema includes two fields customer_name & account_number and depositor schema includes two fields customer_name & loan_number. 
                     @ganeshj86 (255)
 • India
                    4 Oct 09
                    HI development,
Here is an example of sub query.
select * from tablename1 where column1=(select column1 from tablename2);
In this example select * from tablename1.. is the outer query.And (select column1 from tablename2) is the sub query.We say that subquery is nested within outer query.
                    
 
                             
                        
 
                    
