Nested queries, Database Management System

Nested Queries

Let us see some more complex queries in this section.


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:



                 WHERE expr OPERATOR

                                                          (SELECT FROM


                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
Locks: Serialisabilty is just a test whether a given interleaved schedule is ok or has a concurrency related trouble. Though, it does not make sure that the interleaved concurrent

i am required to come up with entities relationships, optionality and cardinality from a scenario. there is a night club and bookings for a musician band

a.  Construct a query around any one of the functional divisions you made in 4a such that if executed in the distributed design of 4 would require reconstruction of at least two ho

Question 1 What is data mining? Write Data Mining applications Question 2 What is OLAP? Write the benefits of OLAP Question 3 What is Business Intelligence? Explai

Read the description below and draw an Entity-Relationship diagram for it. You must use the symbols described in the course materials. This database will help the Parents Assocc

What are the categories of SQL command? SQL commands are separated in to the following categories: 1. Data - Definitition Language 2. Data Manipulation language 3. Dat

How can you connect to the MySQL Server? In order to connect to the MySQL server it is necessary to give the username and password so this be able to done with The following

how can apply joins on table

What are the benefits of prepared statements and place holders? Parameter binding operations automatically handle escaping of characters Encourage Statement reuse

I want a good Microsoft Admin experienced in IIS and SQL Server. They require being able to set it up and administer from then onwards. Experience in Team Foundation Server a