What do you know about subqueries

Showing Answers 1 - 4 of 4 Answers

SaratKumar Puranam

  • Oct 10th, 2005
 

Subqueries will be executed once for the entire parent statement.

  Was this answer useful?  Yes

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


Anil Kumar


Software Developer
Research & Development Section
Tata Steel Jamshedpur
globalanil18@yahoo.co.in

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions