subquery

India
February 23, 2007 10:53am CST
how i define the sub query in my sql
1 person likes this
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.
1 person likes this
@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.