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 is SQL Server Agent? SQL Server agent plays a significant role in the day-to-day tasks of a database administrator (DBA). It is often overlooked as one of the major tools

How does Oracle act as ODBC and give examples of front end uses with ODBC? ODBC achieve portability at the level of the executable by introducing an extra level of indirection.

Relational Algebra is a set of basic operations used to influence the data in relational model. These operations allow the user to specify basic retrieval request. The result of re

What are the uses of functional dependencies? To test relations to see whether they are legal under a given set of functional dependencies. To state constraints on the set

What is meant by heuristic optimisation?Discuss the major heuristics that are applied during query optimisation.

How can i turn a conceptual entity relationship diagram into a logical entity relationship diagram? what do i have to do with "mandetory or" and "optional or" relationships?

It can be easily defined as: The database must not have any unmatched foreign key values. The term "unmatched foreign key value" means a foreign key value for which there doe

Explain forms based and graphical interface? Forms based and graphical interface: graphical user interface (GUI) is a kind of user interface which permits people to interact

What is a block and a block number? A block is a contiguous sequence of sectors from a single track of one platter. Every request specifies the address on the disk to be refere