SaratKumar Puranam
Answered On : Apr 10th, 2006
Subquery is the one which is executed once for the entire parent statement.
Login to rate this answer.
Hi Guys,
A subquery is a SELECT statement that is embedded in a clause of another SQL statement, Called the parent statement.
The subquery (inner query) returns a value that is used by the parent statement. Using a nested subquery is equivalent to performing two sequential queries and using the result of the inner query as the search value in the outer query(main query).
Sub queries can be used for the following purpose:
1. To provide values for conditions in WHERE,HAVING and START with clauses of
SELECT statements
2. To define the set of rows to be inserted into the target table of an INSERT or
CREATE TABLE statement
3. To define the set of rows to be included in a view or snapshot in a CREATE VIEW
or CREATE SNAPSHOT statement
4. To define one or more values to be assigned to existing rows in an
UPDATE statement
5. To define a table to be operated on by a containing query. (YOU do this by
placing the subquery in the FROM clause. This can be done in INSERT, UPDATE
and DELETE statement as well.)
Note : A subquery is evaluted once for the entire statement.
I hope ,you will get your answer. If you have any dought then feel free to mail me on globalanil18@yahoo.co.in
Thanks & Regards
Anil Kumar
Software Developer
Research & Development Section
Tata Steel Jamshedpur
globalanil18@yahoo.co.in
Login to rate this answer.