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
Define the concept of generalization A generalization is relationship between specific kind of thing and general thing. It is also known as "is-a-kind-of" relationship. Inher

#what is cursor its uses ? Explain it

We need help in Booking System for Golf Business Development of a web based booking system which permits clients to book golf lessons with the following features- a) 4 user p

, write the relational schema, and draw the new dependency diagrams. Identify the normal forms for each table structure you created


FDs in Entities : Student entity :                                                Enrolment number →  Student name, Address Course Entity :

Question: a) Discuss the concept of data independence, explaining its importance in a database environment. b) To address the issue of data independence, the ANSI-SPARC t

(a) Data Mining Process : In the context of this cluster analysis project , and in your own words , explain how you would execute the first stage of data mining, namely the "P

What is self-transition? If there is a transition which goes back to same state, it is known as "self- transition." With a trigger action exit action would be executed f

The aims of the project are: 1. To enable the students to undertake the detailed design of a specific plant or process 2. The design projects includes: process selection; und