Nested queries, Database Management System

Nested Queries

Let us see some more complex queries in this section.

Sub-queries:

Some of the basic concerns of sub-queries are:

  • A sub-query is a SELECT statement that is fixed in a clause of another SELECT statement. They are often referred to as a SUB SELECT or NESTED SELECT or INNER SELECT.
  • The sub-query (inner query) implements first before the main query. The product of the sub-query is used by the outer query (main query).
  • Sub-query can be placed in HAVING or WHERE or FROM clauses.
  • Format of using sub-queries:

                 SELECT

                 FROM

                 WHERE expr OPERATOR

                                                          (SELECT FROM

WHERE);

                Operator has a comparison operator (one or multiple row operators)

Single row operator:   >, =, >=, <, <=, <>

                         Multiple row operators: IN, ALL, ANY,

  • Order by clause can't be used in sub-query, if specified it must be the end clause in the main select statement.
  • Parts of sub-queries:

         ‰  Single row sub-query: It gives only single row from the inner select statement.

        ‰   Multiple row sub-queries: It gives more than single row from the inner select statement

        ‰  Multiple column sub-queries: It gives more than single column from the inner select statement.

Single row operators are used with one row sub queries and multiple row operators are used with numerous row sub queries.

  • The Inner and Outer queries can get data from different tables.
  • Group Functions are used in sub queries.
Posted Date: 3/11/2013 3:36:58 AM | Location : United States







Related Discussions:- Nested queries, Assignment Help, Ask Question on Nested queries, Get Answer, Expert's Help, Nested queries Discussions

Write discussion on Nested queries
Your posts are moderated
Related Questions
What are the benefits of prepared statements and place holders? Parameter binding operations automatically handle escaping of characters Encourage Statement reuse

Define entity integrity and referential integrity.  How does SQL allow specification of  these? Ans: Entity Integrity Rule- If the attribute A of relation R is a prime attribut


Explain the disadvantages of using DBMS There could be a few disadvantages of using DBMS. As DBMS requires computers, we have to invest a good amount in acquiring the hardwa

differences between a classified catalog and a dictionary catalog

Database Management Systems 1. Explain SQL Server 2000 Architecture with diagram. 2. Describe Second Normal and Third Normal Form. 3. Explain about query engine and stora

The Locking Protocol: To manage concurrency related problems we use locking. A lock is mainly a variable that is associated with a data item in the database. A lock can be located

The participation Constraints shows whether the existence of an entity depends on its being associated to another entity by the relationship type. There are two kinds of participat

Write short notes on data ware housing? Data ware housing applications needs the transformation of data from many sources into a cohesive reliable step set of data configured a